The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Input Type File, Initial Value Problem

I'm building a web-based file processor and have run into a user interface problem. I want the user to specify the files which they need to process, but I don't want to present them with an arbitrary number of file upload slots on the webpage.

To get around this part, I quickly built an extra screen which has a textarea; the idea being that the user could drag and drop the files onto this textarea. The textarea (at least in Safari) simply shows the filename of the dropped file- perfect. I constructed the next part si that it would parse the textarea and split all of the file locations into an array[1] which would then allow me to create the file upload inputs[2]. The problem is that the file input doesn't allow an initial value! Is there a workaround for this? Your help is much appreciated!

In PHP:

[1]
$files = array();
$files = split("\n", $_REQUEST['files']);

[2]
foreach ($files as $key => $value) {
echo "<input type='file' name='$key' value='$value' size='40' />";
}
Gavin Laking Send private email
Monday, June 12, 2006
 
 
I found a solution which removes the need for multiple input elements, but still relies on the user adding one file at a time which for this particular application will be tiresome.

http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/

Can anyone beat this?! Thanks again!
Gavin Laking Send private email
Monday, June 12, 2006
 
 
A photo development site I know of has multi-file upload, but it required an ActiveX plug-in and so is IE specific.

Maybe you could develop a small file-upload app that could work in concert with the web-page?
Honu Send private email
Monday, June 12, 2006
 
 
"The problem is that the file input doesn't allow an initial value! Is there a workaround for this?"

No.  For security reasons there is very little you can do with uploaded files.  The reason that the file upload control has no initial value (and is not DOM programmable) is to prevent sites from secretly grabbing files from your harddrive.

There is no way to allow easy multi-file uploads without using an external plugin (ActiveX, Java, etc).  You could, maybe, provide a webdav interface or FTP and allow users to upload files that way.
Almost H. Anonymous Send private email
Monday, June 12, 2006
 
 
In hindsight I'd not really considered the security implications of this. I've decided to use the script I mentioned above; putting the responsibility of manually adding each file on member of staff using this. To be honest I was saving seconds not even minutes or hours. Thanks everyone!
Gavin Laking Send private email
Monday, June 12, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz