Go Back   Webmaster Forum > Development > Programming > ASP and ASP.NET
REMOVE the ads below !
Reply
 
LinkBack Thread Tools
  # 1 (permalink)
Old
Junior Geek
Posts: 86
Join Date: Sep 2007
iTrader: (0)
ASP.net Simple File Upload Function - 12-23-2007

I have been coding with ASP.NET for a while and like it for the diverse variations in the code, that allow you code whatever you desire. As of late I've been coding an ASP.NET simple [it's basic but highly dynamic] upload function.

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.

So lets construct this function.

Code:
<asp:FileUpload ID="FileUpload1" runat="server" />
This alerts the server of the operation in which you are wishing to run. It's simple but does the job required easily.
The next step is to include the file upload code:

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.


Freelance CMS - Where Design Meets Development

Web Design and Development Forums | Portfolio
Reply With Quote
  # 2 (permalink)
Old
Senior Geek
Posts: 591
Join Date: Jan 2008
iTrader: (0)
Location: Craiova
05-14-2008

useful, but i need to read more asp.net tutorials
Reply With Quote
Reply


Thread Tools



Advertise Here for just $6 per month

vBulletin®, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. | SEO by vBSEO | Skin developed by vBStyles.com