View Full Version : Custom upload form
01-14-2004, 04:02 PM
I've got a question. Is it possible to build a custom file upload form, and if it is, then how? For example, the form I am building will not be used for English-speaking users, so, I would the "Browse" button to be in the customer's language, but, they are using English OSs. Then, I don't any field at all and I want to control what format (like to reduce to images only) of files can be uploaded. I know that there are some security resctrictions onto file upload fields, but still I would like to know for sure if there is no other way of doing that. Also, is it possible to a file through a POST request using JS?
THanks a lot to everyBUDDY!
01-14-2004, 04:28 PM
Theoretically, you can have a text input next a button, and a hidden file input tied to the button's onclick event:
<input type="text" id="fakeFileName" name="fakeFileName" />
<input type="button" value="Click me to upload!" onclick="this.form.fileField.click();" />
<input type="file" id="fileField" name="fileField" onchange="this.form.fakeFileName.value=this.value;" />
...but that's untested, and probably unsupported in most browsers.
To limit what's accepted, you can filter by mime-type by using the "accept" attribute:
<input type="file" accept="image/*,text/plain-text,application/x-pdf" />
This will let you accept any image, plain-text file, or PDF document that the client wishes to upload. For more on mime-types, visit your local friendly search engine.
<a href="document.forms['myform'].submit()">Submit the form!</a>
Note: this bypasses the form.onsubmit event and its handler(s), so beware. If client-side validation is important, make sure to add that into your script before your submit() method call.
01-14-2004, 05:03 PM
You need a serverside language to upload files. Then just use that language to check which file type is being uploaded.
01-29-2004, 02:25 PM
I gotcha. Can you recommend a good language, on which you could do what I am saying. For example, my customers is uploading a huge file and then at the end he finds out that it's not allowed to download this kind of files, only after he uploaded it, then he calls me and tells me that they don't want to work with me anymore.
I want to make client-side check w/o uploading the file itself.
Thanks guys. I really need a solution for this.
01-31-2004, 02:46 AM
I think you can do this with php...
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.