LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-06-2010, 11:51 AM   #1
miedward
Member
 
Registered: Feb 2007
Distribution: RHEL 4, SOLARIS 10
Posts: 91

Rep: Reputation: 15
php5 problem with uploads from IE using html form input type file


I wrote a web based ftp client using php5 and RAD upload (http://www.radinks.com/upload/) and I am getting strange results when using -some- instances of IE (versions 8,7, and 6 have been tested).

The upload is ultimately getting its information from a simple html form using the input type="file" tag. So the users are all using the "browse" button provided by this tag, moving to a document on their filesystem and clicking submit. In all cases the file uploads succeed. The problem is that on IE in most cases the filename on the server ends up being the full dos path of the file on the client's machine.

For example, if I upload a file "c:/documents and settings/mike/desktop/Image001.jpg" it shows up on the server file system as a single file named "c:/documents and settings/mike/desktop/Image001.jpg". The server is running CentOS 5 and can handle this name, but it is ugly and looks wrong. It also breaks my display and download script, but I can fix that part if I have to deal with these filenames.

On my copy of IE8 and all copies of Firefox 3.6.3 that I have used have worked as expected and shows up on the server as "Image001.jpg".

Any thoughts/workarounds/solutions would be appreciated.
 
Old 04-06-2010, 12:36 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,102

Rep: Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719
Quote:
Originally Posted by miedward View Post
I wrote a web based ftp client using php5 and RAD upload (http://www.radinks.com/upload/) and I am getting strange results when using -some- instances of IE (versions 8,7, and 6 have been tested).

The upload is ultimately getting its information from a simple html form using the input type="file" tag. So the users are all using the "browse" button provided by this tag, moving to a document on their filesystem and clicking submit. In all cases the file uploads succeed. The problem is that on IE in most cases the filename on the server ends up being the full dos path of the file on the client's machine.

For example, if I upload a file "c:/documents and settings/mike/desktop/Image001.jpg" it shows up on the server file system as a single file named "c:/documents and settings/mike/desktop/Image001.jpg". The server is running CentOS 5 and can handle this name, but it is ugly and looks wrong. It also breaks my display and download script, but I can fix that part if I have to deal with these filenames.

On my copy of IE8 and all copies of Firefox 3.6.3 that I have used have worked as expected and shows up on the server as "Image001.jpg".

Any thoughts/workarounds/solutions would be appreciated.
Without poking through the code, I can only suggest to you what I did for my own software: Deny IE and/or put up a big, ugly warning box about using it.

I had similar issues, and decided that I wasn't going to ignore web standards and best programming practices, to 'fix' a browser that was broken. I put a disclaimer that essentially said "use a standards-compliant browser, or quityerbitchen", and moved on. Some folks complained, but most were happy about it, since page loads were faster (less code and work-arounds, obviously), and it forced some managers to quit dragging their feet about upgrading stuff.

Just FWIW.
 
Old 04-06-2010, 01:28 PM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,159

Rep: Reputation: 258Reputation: 258Reputation: 258
Also make sure you have enctype="multipart/form-data" and method="post" as attribute to the form tag in the html. I can't remember seeing such filenames on uploads, but I remember strange things happened without.
 
Old 04-06-2010, 02:24 PM   #4
miedward
Member
 
Registered: Feb 2007
Distribution: RHEL 4, SOLARIS 10
Posts: 91

Original Poster
Rep: Reputation: 15
This is the form. postIt just checks the form for valid data.
The other parts are from the RAD package. I don't believe I made any significant additions or deletions besides some configuration type things.
I can post the rest of it, but it is spread over several files and would be a few pages of code probably.

Code:
<form  enctype="multipart/form-data" action="/cgi-bin/upload.cgi?sid=<?php echo $sid; ?>" method="post">
        <input type="file" name="file[0]">
                <input type="hidden" name="sessionid" value="<?php echo $sid ?>">
                <input type="button" value="Send" onClick="postIt();">
                <!-- uncomment the following to test with out the progress bar -->
                <!input type="submit" value="Send">

</form>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
save input from an online form to a file/database? portia Programming 4 01-30-2010 10:22 AM
HTML form to read/write from local file mustangfanatic01 Linux - Software 2 03-11-2006 04:29 PM
Html Form File Cottsay General 0 11-05-2005 02:30 PM
mod_python: Handling Uploads from HTML Form nko Programming 0 04-12-2005 06:33 PM
problem with html form meluser Linux - Software 4 03-15-2003 01:28 PM


All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration