Today is . Page created 09/19/06

Upload Upload File Filter Filter

Please upload only images that end in:

Allowing visitors to upload files through web forms on your site is useful, but how do you limit the types of files they can upload? This script only allows visitors to upload files that end with the file extensions you want, such as .gif and .jpg, etc.

We have tested the code in IE6.0, Firefox1.5.0.6, Opera9.01, Netscape8.1 and AOL Explorer1.2. This form worked well in all platforms with no variations observed.

For Your Information For your Information:     Before we begin, we feel obligated to advise you that the above form is for all intensive purposes a "Stand Alone" script. In other words, it really does not do much of anything other than what you see. In order to make it function as designed, you need to incorporate it into a valid working form. If you do not have a good Solid Knowledge of HTML coding, javascripts, forms and reconfigurations, please "Do Not Attempt" this until you are Proficient in the aforementioned areas.

Depending on your knowledge of HTML and javascripts, this is an easy two (2) part copy and paste code that goes in both the <HEAD> and <BODY> sections of your document with minimal reconfigurations in the <HEAD> section. This reconfiguration is for the allowable types of files to be uploaded.

<!---- Reconfigurations <HEAD> Section ---->

Default

<!-- Begin
extArray = new Array(".gif", ".jpg", ".png");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)

Reconfigured

<!-- Begin
extArray = new Array(".gif", ".jpg", ".png", ".txt", .ico");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)


Just add the different file type(s) that you want to be allowed to be uploaded. Enclose each one with quotation marks ( " ) and a comma ( , ) with the exception of the last file type where you will not have a comma.





Notice how we added more file types ".txt", and ".ico" to the code. Notice also the lack of a comma ( , ) after the last new addition.

After you have made the reconfigurations to suit your requirements, now all thats left is to incorporate the <BODY> section of code into a functioning form.

We hope our tutorial was easy to follow and we covered everything in detail. If you would like to add this effect into your pages, grab the respective below link and you are there. If you have any problems with this or anything else, feel free to consult our FAQ ] and if you can't find the answer there, contact us ].
Get Code Here ]   [ Rate This Page ]