PDA

Click to See Complete Forum and Search --> : fileupload?


bob323
Oct 3rd, 2002, 08:40 PM
I am using the fileupload text box to get a file name to upload to my server (you know the browse button and the textbox that displays the file path). Was wondering if there is a way to set the types of files that it can find. By default it searches for * all files. I want it to just find textfiles, any ideas?

The Hobo
Oct 3rd, 2002, 09:43 PM
I don't know if there's a parameter for it in HTML, but whatever you're using for the upload (CGI, PHP?) you could check in there and then report it if it's an error.

And you can always cheat the file dialog, even if it says only text files. So you'd need that anyways.

punkpie_uk
Oct 4th, 2002, 03:06 AM
the accept attribute is supposed to let you pass a valid MIME type, but I've never been too successful with it to be honest.


<INPUT TYPE="file" NAME="html_file" ACCEPT="text/html">

Rick Bull
Oct 4th, 2002, 04:08 AM
Yeah I don't think any browser supports it yet. I would probably add a javascript to the onsubmit event of the form that checks (using a regexpr) if the extension is right, and return false if it's not. Then do what the Hobo says a check at the server in case the user has JS disabled.