Page view counter

How Do I: Simple File Uploads in ASP.NET

In this video I will demonstrate, using ASP.NET, uploading a single file from the client machine to your server. This will be the first in a series of uploading files videos.

Presented by Joe Stagner

Duration: 17 minutes, 17 seconds

Date: 12 February 2008

Watch the video   |   Download the video   |   Get VB code  or  C# code

Video downloads: WMV | Zune | iPod | PSP | MPEG-4 | 3GP

Audio downloads: AAC | WMA | MPEG-4 | MPEG-3 | MPEG-2

Comments : 22

Leave a Comment

twkessel : On March 16, 2008 12:08 AM said:

Does anyone know how to change the C# code to upload to a relative directory so it doesn't matter if you change hosting companies?

izraelie : On March 17, 2008 8:22 AM said:

Pls kindly indicate hw to upload image files to

JoeStagner : On March 20, 2008 5:20 PM said:

Server.MapPath(".") will give you the current directy, then you can append the relative path. Remember the app still needs write access to the directory.

laxmikanth2005 : On March 27, 2008 9:07 AM said:

Hi every one,

How can I stop downloading my private videos on web. people are using different third party tool like

* Orbit

* Xilisoft

* VDownloader

* TubeSucker

* VideoGet

they are easily downloading my videos ..is there any solution to stop this type steeling

please give me solution

tx

samiz_z : On April 15, 2008 11:19 AM said:

thanks but i want to knew how to download the file that i have upload

JoeStagner : On April 15, 2008 9:42 PM said:

laxmikanth - if they can view them, they can download them. Really the only solution is to DRM them.

samix - you either need to let the user do a directory listing or you need to create a web link somewhere after uploading.

confimalar : On April 18, 2008 4:18 AM said:

what are the parameters in fileupload.input stream??

MominIjaz : On May 17, 2008 2:37 PM said:

simple way to download is

http://sitename/file.zip

we can also download as Server.MapPath(".")

also.. try msdn.microsoft.com/.../aa478985.aspx

hope this will solve your the issue.

thanks, momin

kolept : On June 17, 2008 10:50 AM said:

Thanks 4 the code

I still need some extra features from this code.

Can u teach me how 2 show the picture I uploaded on top of the uploader controller,simple code in c# no need file type verification. Thanks.

kolept : On June 17, 2008 10:59 AM said:

hi,sorry 4 giving so many comments.But is was not my faults cause the webpage showed I hv error so I keep on posting. Can u help me 2 delete the repeated comments. Thanks

bryanr : On June 18, 2008 1:08 PM said:

Very interesting video and presentation.

Can you advise how to change the code to upload a file from a client PC to a web based server - the ASP FileUpload seems quite happy when the saving location is a physical drive including C:/ or something similar, but not at all for a virtual drive such as http://www.domain.com/storage/

I need to upload an Access mdb from a client computer, on a fairly regular basis (every 3 days or so) to a shared hosting web server where I don't have access to the physical drive - the mdb will then be queried by further ASP pages. The comp0uter operator is not computer savvy so this has to be a painless, automated routine built into an ASP.NET form like the FileUpload systenm you demonstrated

I get the physical system on my own drive OK, but fail when trying to switch to the virtuals systm on the server. I have tried various permutations including Server.MapPath with no luck. Any ideas for me please ? What am I doing wrong ? Do I need to code in UID and PWD for webserver access also ?

Latest attempt at these lines was :

filePath = "http://www.domain.com/storage/" & FileUpLoad1.FileName

FileUpLoad1.SaveAs(Server.MapPath(filePath))

Thanks

BR

tmorton : On June 25, 2008 2:08 PM said:

Hi kolept, I've now removed the duplicate comments and we've corrected the underlying problem with the error message that was occasionally appearing when leaving a video comment.

cv_vikram : On August 09, 2008 8:32 AM said:

thanks 4 the video.......

aslesh : On August 11, 2008 5:05 PM said:

Stagner,

Nice work.. I have a question. when u clcik on the browse button is it possible to show up another computer(i,e instead of uploading it from our computer i need to upload some documets which were located in another server)..

how to do this ?

does FTP do anything with this?

AZtraveler : On August 13, 2008 6:08 PM said:

Great video series and thanks for the information.

I watched all 4 and am now trying to incorporate this into our Intranet and can get this to work with the sample code provided, but am running into problems.  We have a master page that we use for header content on our site.  As you probably know, master pages have the <asp:Content> tag in them.

The question I have is can this work using the MasterPage functionality?

muhammed : On August 14, 2008 1:54 AM said:

thanks for the video

gajanan.shete : On September 21, 2008 2:09 AM said:

Does any one knows how to use inlinecode variable in codebehind i try it,but compiler replay me 'due to protection level u can't access variable or method.',

is there any solution for this

mbgczhao : On October 21, 2008 11:55 AM said:

Does anyone know how to execute a EXE thru a web application? I knew ASPNET is the user for web app, maybe I have to do something on this user's right. But how to? Thanks.

djibril_chimere_DIAW : On October 29, 2008 9:36 AM said:

Thanks ! Jërëjëf !

bnsp4u : On October 29, 2008 10:44 PM said:

Really this video is cool.

where can I find the another 3 video because i didn't find here except first and last one.

Thanks..

TecFX : On November 01, 2008 12:53 AM said:

This was a great tutorial.  Does one exist for adding the FileUpload component to a DetailsView?  I have been searching for a couple of days now and could really use the help.

Thank you in advance.

djafer : On November 11, 2008 1:11 PM said:

Güzel çalışma ne diyelim.

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities