RSS link icon

.

ASP.net Simple File Upload Function


You might already know why I love asp.net and why my website is programmed with the .net language, its because its so easy and simple, everything is made for you, you sometimes you might be limited in functions, but then you can make your own and let in inherit functionality else where.

This time you will se how easy it is to upload a file to your server, this is a must have function on every website with has an administrator back-end, cms system etc.

The smart thing about fileupload is that you dont have to connect to a server or anything, cause this will be done as you are already on the server when you are on the website, if you know what I mean.

One more thing, you will need the file upload control, it can be added like this.


Well here is the file upload code.

If FileUpload1.HasFile Then
FileUpload1.SaveAs(Server.MapPath("The_Name_Of_The_File"))
End If

As you can see its so simple, you just use saveAs then call the server.mappath which calls the current folder on the webserver and lets you give the file a new name to save it.

That is what I call easy coding.


Tens says: 2008-08-07

Thank you! i have no words. Every other tutorial combines this simple piece of code with sql or forms and stuff. Anyway this gives the oportunity to set the rest on our own. Thanks again

mudit says: 2008-03-07

really its simple code...thanks

Arjun says: 2007-12-01

This is a very helpful code.

jewel says: 2007-11-30

its really cool..it can take away away the fear of any one with programming

laknath says: 2007-11-20

nice

lexter_maymay@yahoo.com says: 2007-11-12

that helpful, though there is a way to accurately verify a target fiel using the "posted" method of fileupload.

Jinx says: 2007-10-14

Yes I can see its quite simple, only problem is to have a license for asp.net server or what ever its called.