How to Upload files in ASP .NET
page 1 of 1
Published: 22 Oct 2003
Unedited - Community Contributed
Abstract
Asking the user to upload a file to the server is a very very common task in most of the web applications. In classic ASP, uploading file was a very difficult task, since we need a third party component or we need to write our component to upload file from client to the server. In ASP .NET Uploading a file from client to the web server is so easy. To be precise, we can get this done in two lines of code. Yes, two lines of code. In this article, we will be looking into the following:
by Jesudas Chinnathampi (Das)
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 260947/ 198

How to Upload files in ASP .NET

Asking the user to upload a file to the server is a very very common task in most of the web applications. In classic ASP, uploading file was a very difficult task, since we need a third party component or we need to write our component to upload file from client to the server. In ASP .NET Uploading a file from client to the web server is so easy. To be precise, we can get this done in two lines of code. Yes, two lines of code. In this article, we will be looking into the following:

  1. How to Upload a file from Client to the Web server in ASP .NET?
  2. How to give a different name to the file saved to the web server?
  3. How to know the size of the file uploaded by the user?
  4. How to control the size of file uploaded to the web server?

How to Upload a file from Client to the Web server in ASP .NET?

First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old <input tag, with the type set to File, such as <input type=file id=myFile runat=server />. This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.

myFile.PostedFile.SaveAs("DestinationPath")

Example: Uploading a File in ASP .NET
<html>
<head>
<script language="VB" runat="server">

Sub Upload(Source As Object, e As EventArgs)

   If Not (myFile.PostedFile Is Nothing) Then

      Dim intFileNameLength as Integer
      Dim strFileNamePath as String
      Dim strFileNameOnly as String

      'Logic to find the FileName (excluding the path)
      strFileNamePath = MyFile.PostedFile.FileName
      intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
      strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath)-intFileNameLength)+2)

      myFile.PostedFile.SaveAs("c:\inetpub\wwwroot\yourwebapp\upload\" & strFileNameOnly)
      lblMsg.Text = "File Upload Success."

   End If
End Sub
</script>

</head>
<body>

<h3>File Upload</h3>

<form enctype="multipart/form-data" runat="server">
   File: <input id="myFile" type="file" runat="server">
   <asp:label id=lblMsg runat="server" />
   <input type=button value="Upload" OnServerClick="Upload" runat="server">
</form>

</body>
</html>

Test this Script

In the above example, you should note that, in the FORM tag, we have set the ectype to "multipart/form-data". This is another important aspect while uploading a file to the web server. We have a Input tag which is of type file. Then we have a button called "Upload". On the onclick of the button, you can see that, we are using some string functions to find the FileName (excluding the path). Finally, we invoke the method SaveAs to save the file (upload) in the web server.

How to retrieve the properties of file uploaded by the user?

We can retrieve some of the interesting and useful properties of the file that is uploaded to the webserver. The PostedFile provides us with three important properties, such as FileName, ContentType and ContentLength. In our previous example, we already saw, how to use the property, FileName? Now, we will see, how to know the size of the file uploaded, and how to know the contentType of the file uploaded.

The following line of code retrieves the ContentType of the file uploaded.

lblFileContentType.Text = MyFile.PostedFile.ContentType

The following line of code retrieves the Size of the file uploaded.

lblFileSize.Text = CStr(MyFile.PostedFile.ContentLength)
Now, we will see an example which uses this property.

Example: Uploading a File in ASP .NET
<html>
<head>
<script language="VB" runat="server">

Sub Upload(Source As Object, e As EventArgs)

   If Not (myFile.PostedFile Is Nothing) Then

      Dim intFileNameLength as Integer
      Dim strFileNamePath as String
      Dim strFileNameOnly as String

      'Logic to find the FileName (excluding the path)
      strFileNamePath = MyFile.PostedFile.FileName
      intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
      strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath)-intFileNameLength)+2)

      myFile.PostedFile.SaveAs("c:\inetpub\wwwroot\yourwebapp\upload\" & strFileNameOnly)
      lblMsg.Text = "File Upload Success."
   lblFileContentType.Text = "Content type: " & MyFile.PostedFile.ContentType
   lblFileSize.Text = "File size: " & CStr(MyFile.PostedFile.ContentLength) & " bytes"

   End If
End Sub
</script>

</head>
<body>

<h3>File Upload</h3>

<form enctype="multipart/form-data" runat="server">
   File: <input id="myFile" type="file" runat="server">    <input type=button value="Upload" OnServerClick="Upload" runat="server">
   <asp:label id=lblMsg runat="server" />
   <asp:label id=lblFileContentType runat="server" />
   <asp:label id=lblFileSize runat="server" />
</form>

</body>
</html>

Test this Script

How to control the size of file uploaded to the web server?

While uploading a file to the web server, we have a limit of 4MB by default. We can either decrease or increase this value. The value is set in the key, maxRequestLength of machine config file.

There is a maxRequestLength limit in the machine.config file (look for the <system.web> section), in the httpRuntime settings that you need to alter/raise if you want to accept anything larger than 4Mb. These are the standard settings for the httpRuntime:

<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/>

Links

HTMLInputFile Members
PostedFile Members

Send your comments to das@aspalliance.com        



User Comments

Title: SOFTWARE DEVELOPER   
Name: RAJESH
Date: 4/16/2012 12:59:54 PM
Comment:
uploading a file in asp.net is very easy. I got a complete Idea from this blog

http://sqldecode.blogspot.com/2012/04/uploading-file-in-aspnet-example.html
Title: promlem   
Name: Ravi
Date: 4/2/2012 2:38:56 AM
Comment:
please hlep me, how can send the mail in asp.net. please mention the cod.
Title: Image upload and save in data base   
Name: Ganesh
Date: 3/27/2012 2:24:38 AM
Comment:
Hi, I want to upload an image and store it into data base in asp.net using sql server. for that I have used file upload control in asp.net and I have taken image data type to store in data base. Now How can I retrieve the value from the control and save it into data base.

I dont want to check about the size and type because I am using image data type in data base so that it does not accept any other type.

Please do mail me how to do this
Thanks in Advance
Ganesh
Title: Problem   
Name: Dara Vuthy
Date: 3/12/2012 9:50:01 PM
Comment:
How can i Upload Image File into the Database and show it to our Application.I need Example From You if You can. Thanks
Title: How to upload photos from our application into another Application(Third party any application)   
Name: sampath
Date: 2/25/2012 1:09:36 AM
Comment:
Its nice aticle,can please give suggestions for my query
Title: how to upload file in vb.net   
Name: varsha
Date: 1/16/2012 11:44:47 PM
Comment:
Good articles,thanks
Title: how to upload a folder from a mobile   
Name: priya
Date: 1/2/2012 10:02:07 PM
Comment:
good article. can you please give me a suggestion for uploading a folder from mobile phone.
Title: how to upload a image file and privew it   
Name: ankit
Date: 12/23/2011 6:48:55 AM
Comment:
sir , simple uploding code i know,,i don't know how to upload an image file in asp.net with it's privew without writting an image name,,,please help me in coading
Title: mjd   
Name: MJD
Date: 11/29/2011 8:21:16 AM
Comment:
good
Title: thanks   
Name: Aziz
Date: 11/19/2011 12:45:50 AM
Comment:
thanks for knowledge sharing
Title: hi   
Name: mml
Date: 11/17/2011 3:24:36 PM
Comment:
very Good and thanks
Title: Default profile image upload   
Name: Hem chandra joshi
Date: 11/8/2011 3:16:06 AM
Comment:
how to upload default profile images.
Title: Hi   
Name: Vinay
Date: 10/18/2011 7:30:36 AM
Comment:
How to upload multiple images by pressing ctrl or shift button.
Title: Hi   
Name: Lakshmi
Date: 10/11/2011 1:51:23 AM
Comment:
How to upload photos atruntime in .NET
Title: hi   
Name: nadim
Date: 10/4/2011 2:15:51 PM
Comment:
how to send sms to mobile from mu web site
Title: Hi   
Name: Lakshmi
Date: 9/12/2011 5:02:15 AM
Comment:
how to check praticlar id is in database are not
Title: hi   
Name: aasd
Date: 9/7/2011 5:30:41 AM
Comment:
how can i get 2 fileuploads data into gridview in frontend
Title: help   
Name: zhang
Date: 9/5/2011 4:02:53 AM
Comment:
\
\
Title: Hello   
Name: Emmanuel
Date: 8/18/2011 8:24:57 AM
Comment:
Have you using those code in ASP.net for C# (Ms visual Studio) I need your helps
Title: Hello   
Name: Emmanuel
Date: 8/18/2011 8:24:45 AM
Comment:
Have you using those code in ASP.net for C# (Ms visual Studio) I need you help
Title: multiple doc file uploading   
Name: Girvar singh
Date: 7/28/2011 1:45:53 AM
Comment:
i want code for uploading multiple doc file in asp.net 3.5
Title: multiple file uploading   
Name: Deepika
Date: 7/18/2011 5:06:43 AM
Comment:
I want code for uploading multiple image files in asp 2.0
Title: File Uploading   
Name: PriyaJain
Date: 4/13/2011 2:32:36 AM
Comment:
This code really helps.
I need code to replace uploaded file with existing file.
Title: File Upload   
Name: Suma
Date: 3/4/2011 2:57:49 AM
Comment:
Can you please post C# code for this.........
Title: File upload   
Name: Sindhu
Date: 12/15/2010 11:40:36 AM
Comment:
I can upload the 4 mb file in local pc.When i place the same code in server,i cannot upload file.i can upload file only wihin 1 mb.can you say how can i solve this?
Title: File Upload   
Name: Maulik Patel
Date: 9/30/2010 8:22:15 AM
Comment:
how can i upload the file to my nearest pc which is in lan and i want it in vb6...thanks in advance..
Title: file upload   
Name: Amruta
Date: 9/4/2010 3:51:38 AM
Comment:
I have 2 different server in same domain. kindly guide me how to upload file in asp.net
Title: Alex Fajardo   
Name: STI MUNOZ LIVING PIMPLES
Date: 8/24/2010 5:33:41 AM
Comment:
I tried every code possible to delete my pimples.
I also used SQL SERVER and ORACLE Database to store all my pimple there. But it seem that the storage was not enough to keep all of my pimples. Also, I tried lot's of possible code to disable the retrieval process of my pimples, but it keeps on coming. It populates my face. Please help me debug it. thx
Title: file upload   
Name: Vinitha
Date: 7/1/2010 1:28:29 AM
Comment:
How to select & upload more than one file on a single browse
Title: asp.net   
Name: Addis
Date: 5/4/2010 4:41:42 PM
Comment:
how we insert a picture from any document e.g from Desktop in Asp.net code.
E.g when i want to register any applicant how i upload his/her photo from Desktop?
thanks!
Title: asp.net   
Name: pura
Date: 3/25/2010 2:40:10 AM
Comment:
Inserting Images to SqlServer2005 in ASP .NET 2008 or 2005
anybody knws the code plz help. can one who can assist pls send me the code on pumpeshz@yahoo.com.


This database m working on is msaccess database and migrated to sql but the problem is I can't upload images because when I check images they are binary on sql and don't know what to do ai have tried several times for images but did not manage to do that. pls help.
Title: images   
Name: pumeza
Date: 3/25/2010 2:28:50 AM
Comment:
Hi there

I have tried using your code for uploading images but can't upload images. I got a problem of uploading images from database sql to web form asp.net. pls help
Title: asp.net   
Name: dolly
Date: 2/22/2010 5:32:25 AM
Comment:
please do keep the c# code also here you have only keep the vb
code very very very very very very bad in all you are....
Title: upload the file on server   
Name: gautam
Date: 2/9/2010 5:16:41 AM
Comment:
hi its nice article....any one help me if i want to upload whole folder on server
Title: Gooooood   
Name: Sanjay,Arul from VAJ Consulting Services
Date: 1/7/2010 1:29:41 AM
Comment:
Could anyone send me file uploading programm like yahoo in asp.net
Title: useful   
Name: Harikrishna
Date: 12/29/2009 12:27:54 AM
Comment:
its a useful for all asp users.......
Title: Help   
Name: Helen
Date: 11/13/2009 6:09:05 AM
Comment:
hi,
I have a large document.. about 7MB
I want save it on my SQL BBDD...
Could I save it in small blocks??
thanks!
Title: Good   
Name: Cherukuri Venkateswarlu
Date: 7/6/2009 3:14:40 AM
Comment:
Useful Article.
Title: Query of file upload button   
Name: Vipin Kumar Gupta
Date: 6/22/2009 1:36:53 AM
Comment:
I have a gridview control i want when user click on edit link the fileupload button show but the value of this field which already in database it shows on the text of file control.For example to understand my problem(Like as when we click on edit button the value which is show in label after click it show in the textbox same thing i want to perform with file upload button) Please reply my query.........Will it is possible..........
email id: vipin.gupta.mca@gmail.com
Title: Thanks   
Name: Krishna
Date: 6/19/2009 2:41:01 AM
Comment:
Please help me to retrive the file that we have upload.
Title: this 1 is gud bt pls help me   
Name: pooja
Date: 6/17/2009 11:05:39 AM
Comment:
Can anyone tell me how to select a folder just like a file and i want to add the text files inside that folder to my database,pls help me
u can post ur replies to pooja.bindra@in.com also
thanks
Title: Thanks   
Name: saroj khatiwoda
Date: 5/8/2009 2:26:20 AM
Comment:
Thanks The code work successfully
Title: File Upload   
Name: Adam
Date: 3/10/2009 3:40:21 PM
Comment:
What if someone renames .exe to .doc, how can we catch this
Title: You can use fileupload control   
Name: nipunu
Date: 2/18/2009 7:08:36 AM
Comment:
Good article. You can also use FileUpload control with lots of features
Title: Copy folder from ftp Server to local desktop   
Name: RATHAN
Date: 12/9/2008 3:51:34 AM
Comment:
hi,
Copy folder from ftp Server to local desktop,can any one help?
Title: how to retrive file that we have upload   
Name: fieda
Date: 11/11/2008 5:29:22 AM
Comment:
I want to ask question .. how to retrive the file that we have upload?
Title: Good   
Name: Senthil
Date: 10/16/2008 6:12:20 AM
Comment:
When i m click Browser button i have to show Only Particular type files like JPG,How can i do it.Any Possibility,If it is there please send to my MailID.
Title: uploading image into gridview   
Name: rupa
Date: 9/14/2008 4:14:12 AM
Comment:
hi,i have to upload image into girdview using asp.net(language=vg)with sqldatabase.how can i performe this?please help me.
Title: unloading   
Name: padmshri
Date: 9/10/2008 4:53:11 AM
Comment:
It's really use full... i will sucessfully run the code
Title: File upload   
Name: Ajay Jamwal
Date: 8/29/2008 5:26:22 AM
Comment:
How can i check that same file are not being uploaded twicw or thrice ........???? How to appply validations to check about same file uploaded or not ??
Title: .c# .net uploading a snap   
Name: neha
Date: 7/30/2008 6:25:00 AM
Comment:
how we can upload a image in our website from desktop
Title: How to increase size file upload size   
Name: Kapil Jain
Date: 7/10/2008 11:02:20 AM
Comment:
Hi,
Please let me know how to increase size of file upload through web.config or C# code. I do not want to alter machine.config also we have to provide 15mb restriction to user and if user exceed that size user should see error message; how to achieve this.

Thanks
Title: I am facing a Perfomance issue   
Name: Andy
Date: 7/1/2008 4:18:24 AM
Comment:
Hi,
I am uploading a excel file into the server which is taking lot of time.

I m using ASP and SQL SERVER 2000.

The Connection object i m using is not closed.
and the commandtimeout is set to 9000

What can be a solution for this
Title: How to Upload files in ASP .NET   
Name: Albert
Date: 6/17/2008 8:41:48 PM
Comment:
Very very clean and clear! Thanks for your input.
Title: Mr.   
Name: AJ
Date: 5/22/2008 9:31:23 AM
Comment:
Thank you for this script, you made my work a lot easier I appreciate your help....

AJ
Title: upload files in asp.net and save it to server   
Name: as
Date: 5/12/2008 1:16:21 AM
Comment:
can i have C# coding of above mention article???
Title: How to Upload files in ASP .NET   
Name: Unais
Date: 4/28/2008 5:06:59 AM
Comment:
Can i have the c# coding of the above mentioned article??
Title: head guy   
Name: none of your bussines
Date: 4/6/2008 1:57:52 AM
Comment:
this post probabilly could get to the bottom of uploading images but you can tell it's a theif Title: Nice Code but....
Name: Jitendra Kumar
Date: 11/15/2006 7:09:38 AM
Comment:
this is a nice and helpfull sample of code if there is a user interface like input type=file, but my problem is to upload a file from client's hard disk directly by coding, without using file dialog (ie without any user interface).

If any one has any idea, please tell me.
Thanks in advance.....
Title: Nice   
Name: Sarika
Date: 4/3/2008 3:09:00 AM
Comment:
The material is good and easy to understand. Good Effort
Title: Good   
Name: Priya
Date: 4/2/2008 9:46:10 PM
Comment:
It's really good. Users can understand clearly...
:)
Title: NICE   
Name: Yogesh Deshpande
Date: 3/17/2008 8:00:52 AM
Comment:
The article is very easy to understand and learn.

Thanks
Yogesh
Title: goog   
Name: ahmed
Date: 3/13/2008 7:54:57 AM
Comment:
its very good
Title: sridhhar   
Name: Sridhar
Date: 3/4/2008 7:34:38 AM
Comment:
This is fine
Title: Want a Answer   
Name: Omi
Date: 2/29/2008 6:18:26 AM
Comment:
i want upload the downloaded file directly to upload without download can u tell me how it work
Title: file upload   
Name: Renuka Thakur
Date: 2/27/2008 4:55:28 AM
Comment:
i m not able to upload the image plz send me code
Title: File Upload   
Name: Madhusudhana Rao
Date: 2/27/2008 2:02:07 AM
Comment:
Article is really good and I have a small request that can you implement in c# and send it to me its really required for me.
Title: Question   
Name: Mostafa
Date: 2/22/2008 10:17:46 PM
Comment:
Thanks for saying and giving your vital information but please tell me the answer if you can and i really think that you have answer i have the path of the uploaded file and i want to use it without using default OpenDialogBox inside the control of file input itself please if there is a prepared code send me thanks
Title: Split the image while uploading   
Name: himanshu
Date: 2/12/2008 6:48:28 AM
Comment:
hi,

i want the images to be splited at the upload, so that while displaying if its a big image then that is downloaded one after another and arrange in proper way to for whole of the image. please guide me.

Regards
Title: i want to uploaded file save in database.   
Name: achu
Date: 2/10/2008 4:05:20 AM
Comment:
Inserting Images to SqlServer2005 in ASP .NET 2008...
anybody knws the code plz send to my id anjususanraju@gmail.com...plz..help me.. itz urgent
Title: good 1   
Name: shashank k
Date: 2/6/2008 9:30:02 AM
Comment:
good article. helped my cause. thanks
Title: File Upload Problem through server   
Name: Gaurav
Date: 2/5/2008 7:51:05 AM
Comment:
Good one but your code is not working in my server how I can run the programme and what I have to need to run the programme after upload how we can see the uploaded file in to ftp or any other database.
Title: Need immediate response on files using c#.net   
Name: Sami
Date: 2/4/2008 2:41:19 AM
Comment:
As i want to add the file path to the database but not the file to the database.As i want to see the path information on the database
Title: Need More Information on it   
Name: Vachan Chauhan
Date: 1/29/2008 6:01:30 AM
Comment:
I had gone through this article but i want to add more stuff into this.

actually i am having full file path in string variable on client side..

now i want to upload this string named file to server side..
how can i use FileUpload Input Control as it is read-only..

Is there any where workaround so, i can get this file path and upload this file

Please reply me the rest.
Vachan Chauhan
Email : vachanc@cybage.com
Title: File Upload using Ajax and ASP.Net   
Name: Jai Prakash
Date: 11/16/2007 2:08:59 AM
Comment:
Good!
Your demo shows progress bar and pls.wait...
but using the same your code as in list,I am not getting
the same i.e progress bar and pls.wait.....
Title: not possible to add file load control to other web page   
Name: binu v pillai
Date: 9/29/2007 6:05:33 AM
Comment:
i have created an file upload control but i cant use it in other web page..im developing a user registration form which include a photo uploading section.i made file upload contorl in one web form and other in web user control.first i dragged the web usercontrol to my user page and debugged it.but couldt load it.pls tell how to use a file load contol in other web page
binu v pillai
bvp1@sify.com
Title: image saving in local folder   
Name: chandrakanth
Date: 9/6/2007 6:59:11 AM
Comment:
if u provide this in C# it will helpfull to every one............
Title: Goog for uploading in same machine   
Name: Jiju
Date: 6/14/2007 4:39:05 PM
Comment:
This code is good for testing on same machine since we can type in the direct path but how can we use this code to upload to a network path....?
Title: Only Allowing .jpgs and .gifs to be uploaded   
Name: Monty
Date: 6/14/2007 2:03:24 PM
Comment:
How do you only allow a particular file type to be selected from the browse?
Title: upload file in database   
Name: santosh singh
Date: 6/1/2007 3:06:37 AM
Comment:
i want to uploaded file save in database.
pls giv me code
Title: upload   
Name: sridhar
Date: 5/23/2007 5:56:45 AM
Comment:
good
Title: here there is not given how get this uploaded file   
Name: onkar upadhyay
Date: 4/27/2007 1:57:14 AM
Comment:
thanks
Title: here there is not renaming while uploading   
Name: abhishek agrawal
Date: 4/25/2007 8:01:34 AM
Comment:
hello sir...

you are posted very nice article but there is not the renaming portion but you mentioned hoz to renaming during uploading.i need the renaming files while uploading.
Title: comment   
Name: sree
Date: 4/24/2007 6:57:59 AM
Comment:
it is better if u provide C# code also with this.
Title: time in "user comment" section   
Name: vin
Date: 4/14/2007 5:30:39 AM
Comment:
In user comment (below) in Date:________ part
date is coming right but what about time?????
it is coming wrong.
Check it plz...
Title: How to replace the existing file while uploadng new file?   
Name: Prapthi
Date: 3/16/2007 9:00:16 AM
Comment:
I want replace the existing file and uplaod the same file for the next time. Is it possible?
Title: how to upload a file in ASP.NET   
Name: ATUL SHARMA
Date: 3/14/2007 9:31:43 AM
Comment:
I wanted to know this code in C#, as than only i should rate this article.

Regads
Atul Sharma
Title: Can u help me?   
Name: ajas
Date: 2/23/2007 4:24:29 AM
Comment:
it's realy great,but i wana 2 upload more than one file @ atim ,how it's possible?.
cn u help me?

i mean in windows application we'l use common dialog control and if we set multiselect="true" then we can select more than one file at a time.i want this type in asp.net(web page -vb.net coding) can u help me

plz.. send codings to ajasfrinds@yahoo.com
Title: Validate File Exist   
Name: Ranjith
Date: 2/9/2007 6:09:26 AM
Comment:
Can you help me in validation whether the file is already uploaded before?
Title: how to upload more than 2GB   
Name: Vivek Rathore
Date: 2/6/2007 6:48:00 AM
Comment:
The article is really great and helpful.
But i have discovered that the maximum upload limit can be up to 2GB.If wewants to upload more than 2GB then it's not working.
Any ideas how to overcome it?????

Thanks.
Title: I need Answer   
Name: Mateline
Date: 1/25/2007 10:46:01 AM
Comment:
which better to store pictures in DB or in files

The article Great..thanks
Title: How to upload image and save to new folder in Project with vb.net   
Name: ladda
Date: 1/18/2007 9:29:36 PM
Comment:
i want upload image and save image to new folder in my project how do you do? help me please? language VB.NET
Title: c#.net   
Name: Neeraj Rawat
Date: 1/4/2007 1:06:48 AM
Comment:
Hi Das,
Do u have same script in c#.net. If yes, plz do mail me at email id written above. I shall be thankful to you.

Regards,
Neeraj Rawat
Title: Hi to All   
Name: Shankar.K
Date: 12/26/2006 4:15:16 AM
Comment:
Hi kalpana
i saw ur comments...if there is no file exist in that file in the sence u can show the message "File Not Found"//for this u have to check the file from ur selected path.if no means u can display else u can upload.
i think u knw the kill command...Like wise u can try it also

with regards
shankar from leitenindia(chat at any time for .net doubt:kctshan@yahoo.co.in)
Title: thank you   
Name: R.Brahma chary
Date: 11/24/2006 8:16:28 AM
Comment:
thank u sir..this is very useful to us..i got so many things from this site..once again thanx for sharing ur knowledge
Title: Nice Work   
Name: Raman Pundir
Date: 11/20/2006 3:42:10 AM
Comment:
\
\
\
\
\
Title: Nice Code but....   
Name: Jitendra Kumar
Date: 11/15/2006 7:09:38 AM
Comment:
this is a nice and helpfull sample of code if there is a user interface like input type=file, but my problem is to upload a file from client's hard disk directly by coding, without using file dialog (ie without any user interface).

If any one has any idea, please tell me.
Thanks in advance.....
Title: Thanks   
Name: John
Date: 11/8/2006 6:10:47 AM
Comment:
Thanks for this concise valuable code

John
drstvm@yahoo.com
Title: Thank you   
Name: mamillapalli
Date: 10/18/2006 9:57:33 AM
Comment:
I am accepted with this code but i want something else
if i download the image using this code i am getting only the image but not the data. I want both data and image to be downloaded from sql server 2000. If u provide this i am very thankful to you
Email:pavan_sarmamilla@yahoo.co.in
Title: Thank you   
Name: pavan kumar
Date: 10/18/2006 9:49:43 AM
Comment:
I am accepted with this code but i want something else
if i download the image using this code i am getting only the image that is saved but not the data. I want both data and image to be downloaded from the databse. If u provide this i am very thankful to you

Thanks & Regards
Pavan Kumar
Title: Developer   
Name: Shivam
Date: 10/16/2006 1:27:05 AM
Comment:
Thanks for code,
Can u give the same snippet using C# ?
shivamsharma123@rediffmail.com
Title: developer   
Name: deven
Date: 10/3/2006 9:25:12 AM
Comment:
Yes this link is very helpfull but i am looking for with limitation of extation.i.e. .doc, .xls, .txt something like that. if you have someting like that send me an email on rupa_07@yahoo.com
thanks
Title: File upload   
Name: Jayateerth
Date: 9/22/2006 2:19:27 AM
Comment:
Please, Can you give the same code in c#?
Title: Thanks for all ur effort   
Name: Abhishek Verma
Date: 9/20/2006 3:20:29 PM
Comment:
Your code really work in practice,whether saving and retrieving mages from sql server or uploading files...it is really appreciable...
Title: File upload   
Name: Sanjiv
Date: 9/20/2006 12:03:28 PM
Comment:
Dear Sir,

Article is really good, but i want to know if i don't provide a user interface to the user to select a file from harddrive. then how can i upload a file.
My requireemnt is i want a asp.net page, which will receive a file name through url. is there is any method or procedure that will attach the file with "FileUpload" control and internally executes the page to save the file on fix path on the web server.
I will appreciate your reply on my comment. my email id is sanjeesan@gmail.com.

Best Regards,
Sanjiv
Title: c#.net   
Name: tt
Date: 9/13/2006 12:40:14 AM
Comment:
Do you have example of c#.net
Title: Nice Article   
Name: Rohit
Date: 8/8/2006 11:58:16 AM
Comment:
Do you have anyhthing for if I need to upload file via web services. I need to validate the input file as tab delimited and pass it to the web services into sql server.
I have a problem to upload large file.
Small files are ok.
Title: How to Upload local file on Server Disk   
Name: Mahesh
Date: 7/17/2006 12:56:08 AM
Comment:
\
\
\
\
\
Title: Help needed   
Name: Vimal
Date: 7/11/2006 1:09:30 AM
Comment:
Really nice article.Helps me a lot.Could you give us the suggestions for uploading file from client machine from static location and static file to the server with out using input file control.Pls send ur suggestions at onlyvimal.infotech@gmail.com
Title: Upload file......   
Name: vijay chauhan
Date: 6/30/2006 7:18:08 AM
Comment:
hat's off to u...
gr8 explaination.....
Title: One query   
Name: Muthukumar.S
Date: 6/21/2006 8:42:53 AM
Comment:
I have a application in one machine. While i am trying to upload the file from one machine to another it throws an error like "Could not find the path". I gave the path like this "//ipaddress/folder". My question is if i have to provide any permission for the destination folder which is in the other machine. If so, please provide me the steps that how can we accomplish this task?
Title: good   
Name: hosein khoshraftar
Date: 6/19/2006 4:10:39 PM
Comment:
hello, i am an iranian. it was very good . its helpful for me. thanks
Title: Great code!   
Name: Hrair Kerametlian
Date: 6/17/2006 2:48:52 PM
Comment:
By far, your code works the most smoothly with handling file uploads. Also, thank you for taking the time to explain how to upload files larger than 4MB.

-H
Title: Upload a file in asp.net   
Name: ananda kishore
Date: 6/5/2006 4:04:30 AM
Comment:
I have my application hosted at a server.
What is the path i should give in 'myFile.PostedFile.SaveAs("")' .
Title: Thanks Alot   
Name: Anuj Katoch
Date: 5/26/2006 9:22:44 AM
Comment:
Thanks allot for provind such a use full information.
I tried uploading files and saving.
Your code works very fine.

Keep it up
Title: how do i put the reports   
Name: vishwanatha
Date: 5/26/2006 4:51:53 AM
Comment:
hi sir how do i generate reports with borders,column and rows like in the word doc the reports are placed in a table form .. the similar way i require to generate all reports code in vb.net
Title: interesting   
Name: Mahendra singh
Date: 5/23/2006 6:37:38 AM
Comment:
i like it.
really very knowledge providing Topic
Title: Thanx/Doubts   
Name: Swimmy
Date: 5/20/2006 8:41:46 AM
Comment:
Hi,

Thanx a lot.

I am trying to upload a image file on my server. but i have to check whether the file being uploaded is a picture file ie., with extensions like .gif, .jpeg, jpg, etc and also that it contains truely a picture and not text.

How do i do this in ASP.NET (Language as VB.NET). Kindly help me with this. Waiting for your reply .

Thanking you.

Sincerely,
Swimmy .
Title: Feedback   
Name: Obaid Ullah
Date: 5/15/2006 9:20:24 AM
Comment:
HI,
I read your article its well and easy but its missing something. How to give a different name to the file saved to the web server? This article has no sample code or information given by you. I need much of that
Title: Give full details about fileupload concept   
Name: Martin M A
Date: 4/29/2006 2:49:38 AM
Comment:
i am martin, i saw your upload concept its very usefull to me. but i need full coding so please send to my mailid if it possible .

My id is: tinsworld@gmail.com

thanks
Martin M A
Title: Convert to C#   
Name: Jeerayut
Date: 3/6/2006 10:32:07 PM
Comment:
\
\
\
\
Title: Thanks   
Name: Walter Pastor
Date: 3/2/2006 9:50:05 AM
Comment:
Please, Can you give the same code in c#?
walterpastort@hotmail.com
Title: Article is good but only HTML code is there   
Name: Amit
Date: 2/22/2006 3:19:22 PM
Comment:
Article is good but only HTML code is there ,,,, vb.net or c# cose should be attached.
Title: Multiple file examples   
Name: Jeff
Date: 2/11/2006 7:49:22 PM
Comment:
there is great examples of mulitple file uploads right here - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/UploadASP2.asp
Title: Thanks a lot...   
Name: Niket raut
Date: 2/8/2006 10:25:40 AM
Comment:
Thanks a lot for sharing such a nice article..
Title: Logon failure and bad password   
Name: Zach
Date: 2/1/2006 6:35:52 PM
Comment:
Hi,
This code is awesome but I'm getting "Logon failure and bad password" error whenever it's trying to get pass this line:

txtFileUpload.PostedFile.SaveAs(destPath & fname)

txtFileUpload being the id of the input control. Did anyone have this issue before? I appreciate any help.
Title: Uploading multiple files   
Name: Eric Barr
Date: 2/1/2006 12:15:58 PM
Comment:
Like many others here, I was trying to figure out how to upload multiple files at once without requiring the user to browse to every single file. I couldn't figure out how to do it without a file input field for each file, but since I knew the names of the files, I thought I could just make several file input fields and pre-populate the text boxes with the file paths. But then I got an error saying that the value of the file inputs was not settable. After looking around I unfortunately read this on a site:
"The problem is that the "value" property for this tag is read only. the only mean to fill this field with the value is having the user select a file. This is done for safety reason as otherwise you could upload files from a web client without user permission. And the only mean to upload a local file (with HTML alone) is to use this
tag.
"

I didn't double check anywhere else to confirm that, but it makes a lot of sense. It would be a big security hole if you could upload files from a computer withouth the user acknowledging each file.

Here is the page with that quote.
http://www.issociate.de/board/goto/844904/HTMLInputFile_not_settable.html
Title: ftp folder copy   
Name: Keerthi
Date: 1/29/2006 11:13:04 PM
Comment:
Hi

How can i copy a folder from a FTP server to my desktop.

If you have code for this Please send me

keerthi437@yahoo.com
Title: Very good   
Name: Rajaraman
Date: 1/28/2006 2:52:33 AM
Comment:
Thank you for sharing your knowledge
Title: For Uploading Mutliple Files?   
Name: Pratap Bontha
Date: 1/11/2006 10:04:40 AM
Comment:
No doubt that this article is helpful but, my requirement is to upload multiple files into the application server!
I feel that some configuration needs to be done to the IIS inorder to do this.
I would be grateful to you,if you could solve this problem.

Thanking you,
Pratap
Xinthe Technologies,
India.
Title: Thankyou   
Name: Jon
Date: 1/3/2006 1:05:34 PM
Comment:
nice clear explanation... got it sorted now

thanks!
Title: error   
Name: devs
Date: 12/30/2005 7:34:31 AM
Comment:
hi,it is good one.
it is working fine in my local machine and got error when i hosted it.
help me
with regards
devs_vipin@yahoo.co.in
Title: uploading pblm   
Name: vipin
Date: 12/30/2005 7:31:53 AM
Comment:
hi all,
it is working fine in local machine.
i hosted it in my webserver, there it not working,eror occur??
how i solve...
Title: Must provide these type of important stuff in c#.net also   
Name: vaibhav
Date: 12/28/2005 5:33:04 AM
Comment:
Really great stuff, but plz include code in c# also.
Title: writing to another machine   
Name: piyush parekh
Date: 12/15/2005 2:24:12 AM
Comment:
hi,

this was a fine descirption of uploading a file, this file will be saved in a server. But if i want an web application to load all uploaded files to another machine and not in the webserver machine than how to manage this? plz provide me with answer.
bye,
Thanks

Piyush Parekh
Title: File Upload   
Name: Cathie
Date: 12/10/2005 2:24:35 AM
Comment:
This method works fine when you want to upload the file on application server.But how to upload the file using myFile.PostedFile.SaveAs("") on the another server location.
Or is there any other way to upload it on another server location.
Title: Senior Technical Architect   
Name: Tom
Date: 12/6/2005 2:18:56 AM
Comment:
basic stuff !
Title: Problem!   
Name: Sarada
Date: 12/5/2005 11:39:18 PM
Comment:
Tried to test the script for uploading a file. When I check the root folder, i cannot find the "yourwebapp" folder. I put this code in one of my applications tried. Even then it does not happen. Could u please help me
Title: Good   
Name: Shiva Prasad
Date: 11/24/2005 5:54:03 AM
Comment:
Sir,

I am accepeted with this code, pls suggest me the code to upload the entire folder . if you can do that i will be thankful to you and this i my mail id: gorre_sivaprasad@yahoo.com

regards,
G. Siva Prasad
Title: Lecturer   
Name: Victoria Hilford
Date: 11/15/2005 5:56:27 PM
Comment:
What about being able to upload more than "A" file at the time?
I have found examples of "HARDCODED" number of files that will
use A HARDCODED number of File Input HTML Web controls on
a WEB Form, that allow each to BROWSE and singly select each
file, then one UPLOAD button!

What I would like to see is a HTML WEB Control that will do that?


Some clients have medical images that constitute of a folder with
the subject's name and in the folder each slice (such as MRI images)
is in a file. Thus, typical images have 60 to 200 slices, each one stored
in a file. Thus, what about uploading a folder? That means that the BROWSE
should allow the selection of a folder and the UPLOAD should take care of
uploading ALL the files in the folder!

I would greatly appreciate your feedback.

Thank you,

Victoria Hilford
University of Houston
Computer Science Department
Title: Programmer   
Name: VT.Hiep (HCM-Vietnam)
Date: 11/11/2005 1:53:08 AM
Comment:
The code here works fine but the problem is, when you press F5, it continues uploading!
Next, you cannot upload 2 files with same name because when doing so, there is just one file only!
So upload in ASP.NET is not the right choice!
Please help me out if you could solve these problems.
Thank you
Title: miss   
Name: nirvana
Date: 10/18/2005 3:05:27 AM
Comment:
This code is very helpful and working properly.But can u please send the code to upload files in sql server 2000 database using asp.net(vb script)
Title: Thanks!   
Name: Dev B. Kaushik
Date: 10/14/2005 4:40:32 AM
Comment:
Hi !

Thnks a lot !!!
Gr8 Work !!!
Title: please help!!   
Name: sridevi
Date: 10/3/2005 5:24:54 AM
Comment:
Can you help me out? When I try to write the file to the server I get access denied error
Title: Thanks   
Name: JoJo
Date: 10/3/2005 12:05:45 AM
Comment:
Your explanation is very detail and helps me to understand the coding. Thanks.
Title: folder Uploading   
Name: Ramasamy
Date: 8/31/2005 5:28:27 AM
Comment:
Hello sir,
I had problem in uploading folder
I need to upload the whole folder image one by one to my server folder
(or)
I should save all the file in the client folder to the server database(SQl server 2000 is the database i had image column to save the files)..
I need is it possible to do in... ASP.Net with out using web services... or with using web services
If we can upload using asp.net can you please send me the code or concept to me.
please keep in mind i should save (or) upload all the files in the client folder...


Thanks
can u tell me how to solve this problem
please send the response to
ramasamy.p@gmail.com
Title: Programmer   
Name: Belal Mirza
Date: 8/29/2005 8:54:55 AM
Comment:
You guys are born for superb work and help forpeople like me.Thanks for your excellent code.
Title: Greate site   
Name: B.V.Narasimha Rao
Date: 8/26/2005 10:14:52 AM
Comment:
U r working welll and save our time
Title: help for me   
Name: Nivrutti Khandade
Date: 8/23/2005 4:56:21 AM
Comment:
This article is very helpful Can u give me code to upload files(all files in folder) to server?
Thanks & Regards,
Nivrutti Khandade
Title: log on error   
Name: elizabeth
Date: 8/22/2005 5:24:47 PM
Comment:
I'm trying to create an upload tool for images in c# and asp.net - i have read and write permission for the folder that I'm trying to save the file to, but when I try to upload the file to the server I get an error that says "Logon failure: unknown user name or bad password" Is there any way to specify to the server my login name and password, to make sure that it's getting the correct info?
Title: Upload files   
Name: nicosoft-Tarifa
Date: 8/20/2005 7:04:30 PM
Comment:
That's easy if you use a Desktop computer, bu what if you surf the web with a POCKET PC. The "input" with "file" type is no visible, so you cann't use "Postedfile".
Do you know any way to programmaticaly create that
kind of control in runtime mode.
any help will be apreciate.
Thanks a lot.
Title: Please Help Me   
Name: Gulfam
Date: 8/13/2005 3:42:28 AM
Comment:
\
\
Title: Muchas gracias   
Name: Miguel Angel Rojas
Date: 8/8/2005 5:27:49 PM
Comment:
Muchas gracias por ayudarme, articulos como este son de gran ayuda, y te deseo mucha suerte.....


miguelrh23@yahoo.com
Title: Ms.   
Name: Mana
Date: 7/6/2005 11:52:42 AM
Comment:
This article helped me out tremendously!! Now after I save these files, how would I attach it to an email, and have multiple files?
Title: uploading server   
Name: ashish
Date: 7/4/2005 3:27:00 AM
Comment:
can u give the same code in c#.net
Title: Good Article   
Name: Sayan
Date: 6/16/2005 4:01:52 AM
Comment:
Hi,

This was a good article, really! It would be of greater help to a lot of programmers in the Java fraternity if you can post some snippet of code for a simple or multiple file upload in Java, I mean, in core Java and not using any third party packages. Any help will be really appreciated !

Thanks in advance ...... :)

Regds,
Sayan
Title: need some more   
Name: krishna
Date: 6/16/2005 2:24:59 AM
Comment:
can u tell me how to create a text file on client machine??
Title: uploading image file   
Name: prabhakar
Date: 5/31/2005 10:06:59 AM
Comment:
i want to upload a image file in my application there are some condition
i don't want to specify the path were the file saved, the progame automatically ceate a folder in c deriv
is it possible or not
Title: Upload file   
Name: Priya
Date: 5/27/2005 10:00:31 AM
Comment:
If you will write some text in the file textbox like "ABC" and click upload, the validation is not working.
Title: nice job   
Name: Ken Whaley
Date: 5/18/2005 9:19:02 AM
Comment:
Can you help me out? When I try to write the file to the server I get access denied error.
Title: upload from ASP   
Name: Tenzin
Date: 5/11/2005 5:38:33 AM
Comment:
Can you please give an idea about uploading images using ASP? Can we upload it without using Database?
Please will you help me?
Title: Thanks a lot   
Name: Sree
Date: 5/10/2005 11:33:39 PM
Comment:
This is a useful article and I figured out how to use the same with the C#.

Thanks once agian and keep posting the same thing to help all the programmars,
Title: Mr   
Name: John
Date: 5/10/2005 1:58:46 PM
Comment:
Your article really served my purpose and its well organized.
Thank you very much
Keep Going Guys
Title: if file does not exists!!!!   
Name: kalpana
Date: 4/27/2005 1:42:46 AM
Comment:
in case if the file does not exists in the given path, it creates a new file. wat if we don't want to create new one. it should show some error message like " file not found"
Title: How to Upload files in ASP .NET   
Name: Anil
Date: 4/21/2005 11:10:17 AM
Comment:
U guys are doing great work; Thanks
Title: how to save file (stored on SQL server) to file/web server?   
Name: Thanh
Date: 4/15/2005 2:03:24 PM
Comment:
I got files stored on SQL server db. I would like to be able to save them onto file/web server.

I know how to retrieve them, but not sure how to save to file/web server. Please help. Thanks so much.

Below are codes for retrieving file info from sql server:

Dim strFileName As String = Quote.GetQuoteFileByQuoteFileID(CInt(selectedQuoteFileID)).Tables(0).Rows(0).Item("QuoteFileName")
Dim strFileType As String = Quote.GetQuoteFileByQuoteFileID(CInt(selectedQuoteFileID)).Tables(0).Rows(0).Item("QuoteFileType")
Dim strFileSize As Integer = Quote.GetQuoteFileByQuoteFileID(CInt(selectedQuoteFileID)).Tables(0).Rows(0).Item("QuoteFileSize")
Dim strFileData As Byte() = Quote.GetQuoteFileByQuoteFileID(CInt(selectedQuoteFileID)).Tables(0).Rows(0).Item("QuoteFileData")
Title: Can u give the same snippet using C# ?   
Name: kiran
Date: 4/15/2005 8:14:31 AM
Comment:
Hi.. i found this article very usefull.
But got to say one thing.. plz give the same code snippet using C#, so that i can utilize the same to the maximum extent.
Title: vadildatiom   
Name: fiona
Date: 3/20/2005 5:04:01 AM
Comment:
didn't do validation during uploading. meaning didn't check if the file path is empty, what if it is empty?
Title: Mr   
Name: fahimdidar
Date: 12/13/2004 11:23:12 PM
Comment:
thanks it was agreat help for me
if you could submit an article that could save the file into an other computer in the network pease
Title: Programmer   
Name: Ghassan BELLAN
Date: 12/3/2004 5:07:17 AM
Comment:
This method works when you have a single file to upload but what if we have many files stored in a folder on the client pc and we need to upload them in one time??
NB: Without creating multiple file input controls
Title: appreciation   
Name: Erwin De Leon
Date: 10/5/2004 11:14:33 AM
Comment:
Thank you for being one of the ups! I really appreciate this.
Title: Thank you   
Name: Kyle Huber
Date: 7/20/2004 3:07:30 PM
Comment:
Thank you for sharing your knowledge

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 9/20/2014 11:57:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search