<title></title>
<script src= "Scripts/jquery-1.3.2-vsdoc2.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
function Uploadimage () {
Determine if you have the option to upload files
var Imgpath = $ ("#uploadFile"). Val ();
if (Imgpath = = "") {
Alert ("Please select upload image!) ");
Return
}
Determine the suffix name of the uploaded file
var strextension = imgpath.substr (Imgpath.lastindexof ('. ') + 1);
if (strextension! = ' jpg ' && strextension! = ' gif ')
&& strextension! = ' png ' && strextension! = ' bmp ') {
Alert ("Please select Picture file");
Return
}
$.ajax ({
Type: "POST",
URL: "Handler/uploadimagehandler.ashx",
Data: {imgpath: $ ("#uploadFile"). Val ()},
Cache:false,
Success:function (data) {
Alert ("Upload success");
$ ("#imgDiv"). empty ();
$ ("#imgDiv"). HTML (data);
$ ("#imgDiv"). Show ();
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert ("Upload failed, please check network and retry");
}
});
}
</script>
<body>
<form enctype= "Multipart/form-data" method= "POST" >
<input type= "File" id= "UploadFile" runat= "Server"/>
<input type= "button" id= "Btnupload" value= "OK" onclick= "uploadimage ()"/>
<div id= "Imgdiv" >
</div>
</form>
</body>
jquery File Upload HTML code