Dear Guys, i'm puzzled by my situation. I want to upload a file or files using AjaxFileUpload and i want to filter them by file types (e.g. bmp, jpg, doc, xls). after i filter them, i want to store those files to "~/Savedfiles" and the filenames will be
saved to "Files" table. in AjaxFileUpload, there's a built in Upload button and i want to hide it, instead, i wanna use a custom button so i have the full control in saving it. The reason why i want a custom button because i want to perform another saving
tasks aside from saving external files. I'm using VS 2010 C#. if you guys have some sample code in c# on how to extract multiple file names (in case for multiple uploads), i would really appreciate it. thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class ajaxfileupload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string filePath = "~/upload/" + e.FileName;
AjaxFileUpload1.SaveAs(filePath);
}
}
Please mark the replies as answers if they help or unmark if not.
Feedback to us
jim_rosacena...
Member
32 Points
94 Posts
AjaxFileUpload Properties/Sample Code
Jun 05, 2012 08:42 AM|LINK
Dear Guys, i'm puzzled by my situation. I want to upload a file or files using AjaxFileUpload and i want to filter them by file types (e.g. bmp, jpg, doc, xls). after i filter them, i want to store those files to "~/Savedfiles" and the filenames will be saved to "Files" table. in AjaxFileUpload, there's a built in Upload button and i want to hide it, instead, i wanna use a custom button so i have the full control in saving it. The reason why i want a custom button because i want to perform another saving tasks aside from saving external files. I'm using VS 2010 C#. if you guys have some sample code in c# on how to extract multiple file names (in case for multiple uploads), i would really appreciate it. thanks.
chetan.sarod...
All-Star
66569 Points
11265 Posts
Re: AjaxFileUpload Properties/Sample Code
Jun 06, 2012 03:22 AM|LINK
Please refer this
http://stephenwalther.com/blog/archive/2012/05/01/ajax-control-toolkit-may-2012-release.aspx
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Song-Tian - ...
All-Star
43715 Points
4304 Posts
Microsoft
Re: AjaxFileUpload Properties/Sample Code
Jun 06, 2012 07:31 AM|LINK
Hi,
Please refer to the code as follow:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajaxfileupload.aspx.cs" Inherits="ajaxfileupload" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div> <asp:Label runat="server" ID="myThrobber" Style="display: none;"><img align="absmiddle" alt="" src="images/uploading.gif"/></asp:Label> <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" onuploadcomplete="AjaxFileUpload1_UploadComplete" ThrobberID="myThrobber" MaximumNumberOfFiles="10" AllowedFileTypes="jpg,jpeg"/> </div> </form> </body> </html>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; public partial class ajaxfileupload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { string filePath = "~/upload/" + e.FileName; AjaxFileUpload1.SaveAs(filePath); } }Feedback to us
Develop and promote your apps in Windows Store
jim_rosacena...
Member
32 Points
94 Posts
Re: AjaxFileUpload Properties/Sample Code
Jun 07, 2012 05:44 AM|LINK
thanks a lot guys for your generous ideas. i really appreciate em all and it's a great help. it worked.
jangraanurag
Member
4 Points
3 Posts
Re: AjaxFileUpload Properties/Sample Code
Nov 24, 2012 02:04 AM|LINK
I have to upload multiple files using ajax file uploader can any one plz tell me the code i have to write.............
jangraanurag
Member
4 Points
3 Posts
Re: AjaxFileUpload Properties/Sample Code
Nov 24, 2012 02:04 AM|LINK
I have to upload multiple files using ajax file uploader can any one plz tell me the code i have to write.............