php5 problem with uploads from IE using html form input type file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.