How To Check Upload File Extension Javascript

RegisterLogin
How To Check Upload File Extension Javascript
Post Description: If You Ever Wanted To Know How You Can Verify Or Check What Type Of File Your Users Are Uploading You Will Find This Short Tutorial Helpful Because Webune Is Going To Show You How To
Tags: How, To, Check, Upload, File, Extension, Javascript
This Post Was Posted On Jan 11, 2010 By Webune Tutorials #3034
Welcome to Webune Support Forums

Webune provides Excellent service. Are you tired of your current web hosting provider with their poor service? make the switch to Webune. Sign up today with one of our affordable web hosting plans for your websites!

if you ever wanted to know how you can verify or check what type of file your users are uploading you will find this short tutorial helpful because webune is going to show you how to you can check to see what kind of file your users are uploading on your forms.

DEMO:

(only .jpg files allowed)

Select File:

NOTE: try uploading a .jpg file, then try uploading a different type of file to see the validation.

so how did we do this?

if you wish, you can download the file, we have attached it to this post, or if you want to follow the instructiong given in the reply below in the replies section:
Download File: check-file-extension.html
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
titi
#10065 1
it wowwwww......
Nov 23, 2012 Reply Report abuse
Dharmveer
#9695 2
Nice useful script for check extension of file
May 03, 2012 Reply Report abuse
SimonJPA
#3449 3
thanks dude.

awesome!!!
Feb 11, 2010 Reply Report abuse
Webune Tutorials
#3225 4
Here is the code, to see it in action, open a blank notepad in windows, copy and paste the code below and save it as: checkfile.html - then open it it with your browser!

checkfile.html
<h1>Check File Extension</h1>
<p>Script Provided by <a href="http://www.webune.com">Webune.com</a></p>
<script type="text/javascript" language="javascript">
// SCRIPT PROVIDED BY WWW.WEBUNE.COM WEB HOSTING
function checkfile(){
	var FileExt = document.getElementById('uploadfile').value.lastIndexOf(".jpg")
	if(
	   FileExt==-1) {    
		alert("This File Is Not Allowed");    
		return false;
	}else{
		alert("YES!! - We do allow this file");    
		return true;
	}
}
</script>
<form action="" method="">
Select File: <input type="file" id="uploadfile" name="uploadfile"/>
<input type="button" id="submit" name="submit" value="Upload" onclick="checkfile();"/>
</form>
<p>Find more helpful scripts by Webune at: <a href="http://www.webune.com">www.webune.com</a></p>
<p><a href="http://www.webune.com"><img src="http://www.webune.com/images/headers/default_logo.jpg" border="0" /></a></p>
Thats it

t a g c l o u d: analyze ascertain audit balance account candle case compare confirm correct count enquire about eyeball find out frisk go through investigate keep account look at look over look see make sure monitor note overlook probe prove quiz review scout out scrutinize study take stock tell test try verify
Jan 11, 2010 Reply Report abuse
Leave Your Comments...
©2012 Webune Forums - Sat Nov 24, 2012 5:12 am
Powered by: Webune Forums V3