How to Upload files in ASP .NET
page 1 of 1
Published: 22 Oct 2003
Unedited - Community Contributed
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)
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 39593/ 43

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.


Example: Uploading a File in ASP .NET
<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


<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">


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
<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


<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" />


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"/>


HTMLInputFile Members
PostedFile Members

Send your comments to        

User Comments

Date: 2012-04-16 12:59:54 PM
uploading a file in is very easy. I got a complete Idea from this blog
Title: promlem   
Name: Ravi
Date: 2012-04-02 2:38:56 AM
please hlep me, how can send the mail in please mention the cod.
Title: Image upload and save in data base   
Name: Ganesh
Date: 2012-03-27 2:24:38 AM
Hi, I want to upload an image and store it into data base in using sql server. for that I have used file upload control in 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
Title: Problem   
Name: Dara Vuthy
Date: 2012-03-12 9:50:01 PM
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: 2012-02-25 1:09:36 AM
Its nice aticle,can please give suggestions for my query
Title: how to upload file in   
Name: varsha
Date: 2012-01-16 11:44:47 PM
Good articles,thanks
Title: how to upload a folder from a mobile   
Name: priya
Date: 2012-01-02 10:02:07 PM
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: 2011-12-23 6:48:55 AM
sir , simple uploding code i know,,i don't know how to upload an image file in with it's privew without writting an image name,,,please help me in coading
Title: mjd   
Name: MJD
Date: 2011-11-29 8:21:16 AM
Title: thanks   
Name: Aziz
Date: 2011-11-19 12:45:50 AM
thanks for knowledge sharing
Title: hi   
Name: mml
Date: 2011-11-17 3:24:36 PM
very Good and thanks
Title: Default profile image upload   
Name: Hem chandra joshi
Date: 2011-11-08 3:16:06 AM
how to upload default profile images.
Title: Hi   
Name: Vinay
Date: 2011-10-18 7:30:36 AM
How to upload multiple images by pressing ctrl or shift button.
Title: Hi   
Name: Lakshmi
Date: 2011-10-11 1:51:23 AM
How to upload photos atruntime in .NET
Title: hi   
Name: nadim
Date: 2011-10-04 2:15:51 PM
how to send sms to mobile from mu web site
Title: Hi   
Name: Lakshmi
Date: 2011-09-12 5:02:15 AM
how to check praticlar id is in database are not
Title: hi   
Name: aasd
Date: 2011-09-07 5:30:41 AM
how can i get 2 fileuploads data into gridview in frontend
Title: help   
Name: zhang
Date: 2011-09-05 4:02:53 AM
Title: Hello   
Name: Emmanuel
Date: 2011-08-18 8:24:57 AM
Have you using those code in for C# (Ms visual Studio) I need your helps
Title: Hello   
Name: Emmanuel
Date: 2011-08-18 8:24:45 AM
Have you using those code in for C# (Ms visual Studio) I need you help
Title: multiple doc file uploading   
Name: Girvar singh
Date: 2011-07-28 1:45:53 AM
i want code for uploading multiple doc file in 3.5
Title: multiple file uploading   
Name: Deepika
Date: 2011-07-18 5:06:43 AM
I want code for uploading multiple image files in asp 2.0
Title: File Uploading   
Name: PriyaJain
Date: 2011-04-13 2:32:36 AM
This code really helps.
I need code to replace uploaded file with existing file.
Title: File Upload   
Name: Suma
Date: 2011-03-04 2:57:49 AM
Can you please post C# code for this.........
Title: File upload   
Name: Sindhu
Date: 2010-12-15 11:40:36 AM
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: 2010-09-30 8:22:15 AM
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: 2010-09-04 3:51:38 AM
I have 2 different server in same domain. kindly guide me how to upload file in
Title: Alex Fajardo   
Date: 2010-08-24 5:33:41 AM
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: 2010-07-01 1:28:29 AM
How to select & upload more than one file on a single browse
Name: Addis
Date: 2010-05-04 4:41:42 PM
how we insert a picture from any document e.g from Desktop in code.
E.g when i want to register any applicant how i upload his/her photo from Desktop?
Name: pura
Date: 2010-03-25 2:40:10 AM
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

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: 2010-03-25 2:28:50 AM
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 pls help
Name: dolly
Date: 2010-02-22 5:32:25 AM
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: 2010-02-09 5:16:41 AM
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: 2010-01-07 1:29:41 AM
Could anyone send me file uploading programm like yahoo in
Title: useful   
Name: Harikrishna
Date: 2009-12-29 12:27:54 AM
its a useful for all asp users.......
Title: Help   
Name: Helen
Date: 2009-11-13 6:09:05 AM
I have a large document.. about 7MB
I want save it on my SQL BBDD...
Could I save it in small blocks??
Title: Good   
Name: Cherukuri Venkateswarlu
Date: 2009-07-06 3:14:40 AM
Useful Article.
Title: Query of file upload button   
Name: Vipin Kumar Gupta
Date: 2009-06-22 1:36:53 AM
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:
Title: Thanks   
Name: Krishna
Date: 2009-06-19 2:41:01 AM
Please help me to retrive the file that we have upload.
Title: this 1 is gud bt pls help me   
Name: pooja
Date: 2009-06-17 11:05:39 AM
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 also
Title: Thanks   
Name: saroj khatiwoda
Date: 2009-05-08 2:26:20 AM
Thanks The code work successfully
Title: File Upload   
Name: Adam
Date: 2009-03-10 3:40:21 PM
What if someone renames .exe to .doc, how can we catch this
Title: You can use fileupload control   
Name: nipunu
Date: 2009-02-18 7:08:36 AM
Good article. You can also use FileUpload control with lots of features
Title: Copy folder from ftp Server to local desktop   
Date: 2008-12-09 3:51:34 AM
Copy folder from ftp Server to local desktop,can any one help?
Title: how to retrive file that we have upload   
Name: fieda
Date: 2008-11-11 5:29:22 AM
I want to ask question .. how to retrive the file that we have upload?
Title: Good   
Name: Senthil
Date: 2008-10-16 6:12:20 AM
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: 2008-09-14 4:14:12 AM
hi,i have to upload image into girdview using can i performe this?please help me.
Title: unloading   
Name: padmshri
Date: 2008-09-10 4:53:11 AM
It's really use full... i will sucessfully run the code
Title: File upload   
Name: Ajay Jamwal
Date: 2008-08-29 5:26:22 AM
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: 2008-07-30 6:25:00 AM
how we can upload a image in our website from desktop
Title: How to increase size file upload size   
Name: Kapil Jain
Date: 2008-07-10 11:02:20 AM
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.

Title: I am facing a Perfomance issue   
Name: Andy
Date: 2008-07-01 4:18:24 AM
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: 2008-06-17 8:41:48 PM
Very very clean and clear! Thanks for your input.
Title: Mr.   
Name: AJ
Date: 2008-05-22 9:31:23 AM
Thank you for this script, you made my work a lot easier I appreciate your help....

Title: upload files in and save it to server   
Name: as
Date: 2008-05-12 1:16:21 AM
can i have C# coding of above mention article???
Title: How to Upload files in ASP .NET   
Name: Unais
Date: 2008-04-28 5:06:59 AM
Can i have the c# coding of the above mentioned article??
Title: head guy   
Name: none of your bussines
Date: 2008-04-06 1:57:52 AM
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
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: 2008-04-03 3:09:00 AM
The material is good and easy to understand. Good Effort
Title: Good   
Name: Priya
Date: 2008-04-02 9:46:10 PM
It's really good. Users can understand clearly...
Title: NICE   
Name: Yogesh Deshpande
Date: 2008-03-17 8:00:52 AM
The article is very easy to understand and learn.

Title: goog   
Name: ahmed
Date: 2008-03-13 7:54:57 AM
its very good
Title: sridhhar   
Name: Sridhar
Date: 2008-03-04 7:34:38 AM
This is fine
Title: Want a Answer   
Name: Omi
Date: 2008-02-29 6:18:26 AM
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: 2008-02-27 4:55:28 AM
i m not able to upload the image plz send me code
Title: File Upload   
Name: Madhusudhana Rao
Date: 2008-02-27 2:02:07 AM
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: 2008-02-22 10:17:46 PM
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: 2008-02-12 6:48:28 AM

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.

Title: i want to uploaded file save in database.   
Name: achu
Date: 2008-02-10 4:05:20 AM
Inserting Images to SqlServer2005 in ASP .NET 2008...
anybody knws the code plz send to my id me.. itz urgent
Title: good 1   
Name: shashank k
Date: 2008-02-06 9:30:02 AM
good article. helped my cause. thanks
Title: File Upload Problem through server   
Name: Gaurav
Date: 2008-02-05 7:51:05 AM
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   
Name: Sami
Date: 2008-02-04 2:41:19 AM
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: 2008-01-29 6:01:30 AM
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 :
Title: File Upload using Ajax and ASP.Net   
Name: Jai Prakash
Date: 2007-11-16 2:08:59 AM
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: 2007-09-29 6:05:33 AM
i have created an file upload control but i cant use it in other web 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
Title: image saving in local folder   
Name: chandrakanth
Date: 2007-09-06 6:59:11 AM
if u provide this in C# it will helpfull to every one............
Title: Goog for uploading in same machine   
Name: Jiju
Date: 2007-06-14 4:39:05 PM
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: 2007-06-14 2:03:24 PM
How do you only allow a particular file type to be selected from the browse?
Title: upload file in database   
Name: santosh singh
Date: 2007-06-01 3:06:37 AM
i want to uploaded file save in database.
pls giv me code
Title: upload   
Name: sridhar
Date: 2007-05-23 5:56:45 AM
Title: here there is not given how get this uploaded file   
Name: onkar upadhyay
Date: 2007-04-27 1:57:14 AM
Title: here there is not renaming while uploading   
Name: abhishek agrawal
Date: 2007-04-25 8:01:34 AM
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: 2007-04-24 6:57:59 AM
it is better if u provide C# code also with this.
Title: time in "user comment" section   
Name: vin
Date: 2007-04-14 5:30:39 AM
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: 2007-03-16 9:00:16 AM
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   
Date: 2007-03-14 9:31:43 AM
I wanted to know this code in C#, as than only i should rate this article.

Atul Sharma
Title: Can u help me?   
Name: ajas
Date: 2007-02-23 4:24:29 AM
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 page coding) can u help me

plz.. send codings to
Title: Validate File Exist   
Name: Ranjith
Date: 2007-02-09 6:09:26 AM
Can you help me in validation whether the file is already uploaded before?
Title: how to upload more than 2GB   
Name: Vivek Rathore
Date: 2007-02-06 6:48:00 AM
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?????

Title: I need Answer   
Name: Mateline
Date: 2007-01-25 10:46:01 AM
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   
Name: ladda
Date: 2007-01-18 9:29:36 PM
i want upload image and save image to new folder in my project how do you do? help me please? language VB.NET
Name: Neeraj Rawat
Date: 2007-01-04 1:06:48 AM
Hi Das,
Do u have same script in If yes, plz do mail me at email id written above. I shall be thankful to you.

Neeraj Rawat
Title: Hi to All   
Name: Shankar.K
Date: 2006-12-26 4:15:16 AM
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
Title: thank you   
Name: R.Brahma chary
Date: 2006-11-24 8:16:28 AM
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: 2006-11-20 3:42:10 AM
Title: Nice Code but....   
Name: Jitendra Kumar
Date: 2006-11-15 7:09:38 AM
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: 2006-11-08 6:10:47 AM
Thanks for this concise valuable code

Title: Thank you   
Name: mamillapalli
Date: 2006-10-18 9:57:33 AM
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
Title: Thank you   
Name: pavan kumar
Date: 2006-10-18 9:49:43 AM
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: 2006-10-16 1:27:05 AM
Thanks for code,
Can u give the same snippet using C# ?
Title: developer   
Name: deven
Date: 2006-10-03 9:25:12 AM
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
Title: File upload   
Name: Jayateerth
Date: 2006-09-22 2:19:27 AM
Please, Can you give the same code in c#?
Title: Thanks for all ur effort   
Name: Abhishek Verma
Date: 2006-09-20 3:20:29 PM
Your code really work in practice,whether saving and retrieving mages from sql server or uploading is really appreciable...
Title: File upload   
Name: Sanjiv
Date: 2006-09-20 12:03:28 PM
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 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

Best Regards,
Name: tt
Date: 2006-09-13 12:40:14 AM
Do you have example of
Title: Nice Article   
Name: Rohit
Date: 2006-08-08 11:58:16 AM
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: 2006-07-17 12:56:08 AM
Title: Help needed   
Name: Vimal
Date: 2006-07-11 1:09:30 AM
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
Title: Upload file......   
Name: vijay chauhan
Date: 2006-06-30 7:18:08 AM
hat's off to u...
gr8 explaination.....
Title: One query   
Name: Muthukumar.S
Date: 2006-06-21 8:42:53 AM
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: 2006-06-19 4:10:39 PM
hello, i am an iranian. it was very good . its helpful for me. thanks
Title: Great code!   
Name: Hrair Kerametlian
Date: 2006-06-17 2:48:52 PM
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.

Title: Upload a file in   
Name: ananda kishore
Date: 2006-06-05 4:04:30 AM
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: 2006-05-26 9:22:44 AM
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: 2006-05-26 4:51:53 AM
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
Title: interesting   
Name: Mahendra singh
Date: 2006-05-23 6:37:38 AM
i like it.
really very knowledge providing Topic
Title: Thanx/Doubts   
Name: Swimmy
Date: 2006-05-20 8:41:46 AM

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.

Swimmy .
Title: Feedback   
Name: Obaid Ullah
Date: 2006-05-15 9:20:24 AM
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: 2006-04-29 2:49:38 AM
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:

Martin M A
Title: Convert to C#   
Name: Jeerayut
Date: 2006-03-06 10:32:07 PM
Title: Thanks   
Name: Walter Pastor
Date: 2006-03-02 9:50:05 AM
Please, Can you give the same code in c#?
Title: Article is good but only HTML code is there   
Name: Amit
Date: 2006-02-22 3:19:22 PM
Article is good but only HTML code is there ,,,, or c# cose should be attached.
Title: Multiple file examples   
Name: Jeff
Date: 2006-02-11 7:49:22 PM
there is great examples of mulitple file uploads right here -
Title: Thanks a lot...   
Name: Niket raut
Date: 2006-02-08 10:25:40 AM
Thanks a lot for sharing such a nice article..
Title: Logon failure and bad password   
Name: Zach
Date: 2006-02-01 6:35:52 PM
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: 2006-02-01 12:15:58 PM
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

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.
Title: ftp folder copy   
Name: Keerthi
Date: 2006-01-29 11:13:04 PM

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

If you have code for this Please send me
Title: Very good   
Name: Rajaraman
Date: 2006-01-28 2:52:33 AM
Thank you for sharing your knowledge
Title: For Uploading Mutliple Files?   
Name: Pratap Bontha
Date: 2006-01-11 10:04:40 AM
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,
Xinthe Technologies,
Title: Thankyou   
Name: Jon
Date: 2006-01-03 1:05:34 PM
nice clear explanation... got it sorted now

Title: error   
Name: devs
Date: 2005-12-30 7:34:31 AM
hi,it is good one.
it is working fine in my local machine and got error when i hosted it.
help me
with regards
Title: uploading pblm   
Name: vipin
Date: 2005-12-30 7:31:53 AM
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 also   
Name: vaibhav
Date: 2005-12-28 5:33:04 AM
Really great stuff, but plz include code in c# also.
Title: writing to another machine   
Name: piyush parekh
Date: 2005-12-15 2:24:12 AM

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.

Piyush Parekh
Title: File Upload   
Name: Cathie
Date: 2005-12-10 2:24:35 AM
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: 2005-12-06 2:18:56 AM
basic stuff !
Title: Problem!   
Name: Sarada
Date: 2005-12-05 11:39:18 PM
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: 2005-11-24 5:54:03 AM

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:

G. Siva Prasad
Title: Lecturer   
Name: Victoria Hilford
Date: 2005-11-15 5:56:27 PM
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: 2005-11-11 1:53:08 AM
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: 2005-10-18 3:05:27 AM
This code is very helpful and working properly.But can u please send the code to upload files in sql server 2000 database using script)
Title: Thanks!   
Name: Dev B. Kaushik
Date: 2005-10-14 4:40:32 AM
Hi !

Thnks a lot !!!
Gr8 Work !!!
Title: please help!!   
Name: sridevi
Date: 2005-10-03 5:24:54 AM
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: 2005-10-03 12:05:45 AM
Your explanation is very detail and helps me to understand the coding. Thanks.
Title: folder Uploading   
Name: Ramasamy
Date: 2005-08-31 5:28:27 AM
Hello sir,
I had problem in uploading folder
I need to upload the whole folder image one by one to my server folder
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 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...

can u tell me how to solve this problem
please send the response to
Title: Programmer   
Name: Belal Mirza
Date: 2005-08-29 8:54:55 AM
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: 2005-08-26 10:14:52 AM
U r working welll and save our time
Title: help for me   
Name: Nivrutti Khandade
Date: 2005-08-23 4:56:21 AM
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: 2005-08-22 5:24:47 PM
I'm trying to create an upload tool for images in c# and - 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: 2005-08-20 7:04:30 PM
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: 2005-08-13 3:42:28 AM
Title: Muchas gracias   
Name: Miguel Angel Rojas
Date: 2005-08-08 5:27:49 PM
Muchas gracias por ayudarme, articulos como este son de gran ayuda, y te deseo mucha suerte.....
Title: Ms.   
Name: Mana
Date: 2005-07-06 11:52:42 AM
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: 2005-07-04 3:27:00 AM
can u give the same code in
Title: Good Article   
Name: Sayan
Date: 2005-06-16 4:01:52 AM

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 ...... :)

Title: need some more   
Name: krishna
Date: 2005-06-16 2:24:59 AM
can u tell me how to create a text file on client machine??
Title: uploading image file   
Name: prabhakar
Date: 2005-05-31 10:06:59 AM
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: 2005-05-27 10:00:31 AM
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: 2005-05-18 9:19:02 AM
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: 2005-05-11 5:38:33 AM
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: 2005-05-10 11:33:39 PM
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: 2005-05-10 1:58:46 PM
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: 2005-04-27 1:42:46 AM
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: 2005-04-21 11:10:17 AM
U guys are doing great work; Thanks
Title: how to save file (stored on SQL server) to file/web server?   
Name: Thanh
Date: 2005-04-15 2:03:24 PM
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: 2005-04-15 8:14:31 AM
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: 2005-03-20 5:04:01 AM
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: 2004-12-13 11:23:12 PM
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: 2004-12-03 5:07:17 AM
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: 2004-10-05 11:14:33 AM
Thank you for being one of the ups! I really appreciate this.
Title: Thank you   
Name: Kyle Huber
Date: 2004-07-20 3:07:30 PM
Thank you for sharing your knowledge

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2024  |  Page Processed at 2024-05-29 11:33:23 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search