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!

Choopernickel

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:

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 post request cannot be faked (which would equal being constructed completely in javascript), but a form post can be triggered with the form.submit() method.

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.

Good questions.

Nightfire

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.

rsp12uk

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.