In previous article I explained jQuery lightbox image slideshow, Generate thumbnail from images, Generate thumbnails from YouTube videos using JQuery, jQuery password strength examples and many articles relating to JQuery, asp.net, SQL Server etc. Now I will explain how to upload multiple files in asp.net using uploadify plugin in JQuery.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>jQuery Upload multiple files in asp.net</title>
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<link href="uploadify.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.uploadify.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function()
{
$("#file_upload").uploadify({
'swf': 'uploadify.swf',
'uploader': 'Handler.ashx',
'cancelImg': 'cancel.png',
'buttonText': 'Select Files',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'multi': true,
'auto': true
});
})
</script>
</head>
<body>
<form id="form1"
runat="server">
<div>
<asp:FileUpload ID="file_upload"
runat="server"
/>
</div>
</form>
</body>
</html>
|
<%@ WebHandler Language="C#"
Class="Handler"
%>
using System.Web;
public class Handler : IHttpHandler
{
public void
ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
HttpPostedFile uploadFiles = context.Request.Files["Filedata"];
string pathToSave = HttpContext.Current.Server.MapPath("~/UploadFiles/") +
uploadFiles.FileName;
uploadFiles.SaveAs(pathToSave);
}
public bool
IsReusable {
get {
return false;
}
}
}
|
Imports System.Web
Public Class
Handler2 : Implements IHttpHandler
Public Sub
ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
Dim uploadFiles As
HttpPostedFile = context.Request.Files("Filedata")
Dim pathToSave As String = HttpContext.Current.Server.MapPath("~/UploadFiles/") &
uploadFiles.FileName
uploadFiles.SaveAs(pathToSave)
End Sub
Public ReadOnly Property IsReusable() As
Boolean Implements
IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
|


Subscribe by RSS
Subscribe by Email
19 comments :
nothing will happen your demo
Hi sir, your site is very helpful.
How to send automatic emails based on schedule i.e once in a week/once in two weeks / once in a month??
i have a column in a table for defining schedule. if the schedule is "Once in week" then mails should be sent automatically once in a week, or if the schedule is "Once in two weeks" then mails should be sent once in two weeks,or if the schedule is "Once in a month" then mail should be sent once in a month.
please give me best idea or code for schedule emails.
Thank you.
your fileupload is not working in mozilaFirefox...
@Suraj singh bhati...it will work i hope you need to update your flash player...
hi m saranya , ur blog useful for me,superb ,i can easily understand ..
using jquery concept
(script file its missing)
that link i can't found where is it ...can u reply me soon its useful for me ..thanks.........
you can get those files from attached sample or the uploadify plugin link which was provided above. please check it
Sir as usual your work is tremendous and very helpful to me Sir, can you please guide me My final B.Tech Project is a Website which is a combination of both Gmail(mailing website ) and Facebook type website now I required help on HOW TO RECIEVE MAILS AND WHICH EMAIL SERVER IS PREFERABLE ACCORDING TO YOU TO HOST MY WEBSITE AND HOW TO DO CHAT IF YOU ALLOW ME I CAN SEND YOU MY OWN CHAT CODE WHICH I RENDER FROM MY SENIOR AND HOW TO CREATE A COMMENT LIKE PAGE OF FACEBOOK I CREATED ONE WHERE I CAN UPDATE MY STATUS BUT HOW TO ALLOW COMMENT ON IT
Error:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
sir how to upload videos pls tell
Sir,
It is not working in internet explorer 9...However i tried it on chrome ..it is running good.
Can it be made to work with IE also?
Not working online (HTTP ERROR 500)
I have problem in file upload control.
how to 1GB file upload Server side in asp.net.could u help me
sir its not working could u give me any other tutorial same as it???
Object reference not set to an instance of an object.
show error in this line
string pathToSave = HttpContext.Current.Server.MapPath("~/UploadFiles/") + uploadFiles.FileName;
i tried it bt its nt wrking.....!!!!!
It very nice.
How i do insert to databse and show image in page?
Thanks sir , it is working fine.
this is not working in my site which is having master pages.
If we have fileupload inside the ajax modalpopupextender it was not initialized Can u please explain me why