Fun Infused Games  |   Smooth Operator  |   Evil Scale  |   Starcraft Live  |   Wellplayed.net RSS Feed Available RSS 

  Home   |    Archive   |    Subscribe   |    Search   |    About

Posts prior to 8/2/2010 may be missing data. If you need one of those posts, please contact kriswd40@yahoo.com and I will try and recover/find it.

Upload Files from an ASP.net Webpage
Date 11/25/2009    Tags ASP.net, Tutorial    (2)

Often I find a need to upload files (ussually images) directly from a webpage to my web server. Sure I could use FTP or Visual Studio (Publish Website), but it's a heck of a lot easier if I have a simple webpage interface to do so.

The following code will allow you to upload as many as five files at once (this can easily be changed by simply adding or removing the file input controls from the page) and return whether the upload was successful or what errors were encountered.

In the .aspx file, setup the controls for entering your files and uploading them:

<b><font size=4>Upload Files</font></b><br />
<br />

<asp:Label ID="lblMessage" runat="server" ForeColor="Red" />

<asp:Panel ID="pnlUploadFiles" runat="server">
Use the below form to upload files to the web server. You may upload up to five files at once.<br />
<br />
<br />

Upload files to: 

<asp:DropDownList ID="ddlDirectory" runat="server">
    <asp:ListItem Value="images" Text="Images" />
</asp:DropDownList>


<br />
<br />

<input ID="myFile1" type="File" runat="Server" size="50" /><br />
<input ID="myFile2" type="File" runat="Server" size="50" /><br />
<input ID="myFile3" type="File" runat
                    
Wellplayed.net
This article has been view 17 times.

Advertisement:

Comments

Tim Powell

Avatar

11/26/2009 4:34:02 AM

This in my opinion isn't a fantastic example on how to upload multiple files but I do agree it works and there aren't many ways around this without adding in more XHTML.

We have being doing some research into uploading multiple files using AJAX and posting the file to the server. Unfortunately the only way we have managed to access the client details thus far is via FLASH & AJAX.

Hope this information helps you to create a new file upload that allows more than one file to be uploaded at a time without having to write extra code. :)"0"<
Kris

Avatar

12/1/2009 7:11:50 AM

The reason I did the big loop in the code behind was so that all you need to do is drop in another input control and suddenly you can upload one more file, but that's not dynamic.

Something similar (but slicker) could be accomplished using AJAX to dynamically add new input controls (either automagically as one was filled in or with an "add file" button) and then use largely the same code for saving them.

Creating something that dynamic really wasn't my goal with this tutorial as much as it was creating something that was functionally useful. Perhaps some day I will, but I'm not making an promises.<


Add Comments

Current disabled. Check back soon!
top
top


top
Tags
ASP.net (17)  Annoyances (4)  Video Games (6)  Sage-Like Advice (12)  Domain Name (1)  Internet (5)  NFL (2)  Writing (1)  Visual Studio (1)  Hypership (12)  Site News (2)  Xbox (1)  C# (15)  Sage-Like Advise (1)  Education (1)  Tech Support (1)  MSSQL (1)  Absurd (1)  Abduction Action! (27)  Nasty (36)  Economy (1)  Cool (2)  Sports (11)  .Net (1)  Web Tools (2)  Abduction! (1)  Rant (40)  XBLIG (20)  Tutorial (2)  Nastier (1)  Books (1)  Realty (1)  Programming (3)  Weird (1)  Vista (1)  Development (14)  Design (3)  XNA (35)  Links (1)  Security (2)  JavaScript (7)  CSS (1)  Video (2)  Web Development (1)  Computing (1)  Abudction Action! (1)  Popularity (1)  Game Design (4)  Google (1)  AJAX (4)  Game Development (8)  
top

top
top


Twitter

    Follow me on Twitter



    Buy My Games:
    Abduction Action!
    Nasty

    I'm with Coco.