multiple file upload with description c#

Flórida Araújo 1 Reputation point


Does anyone know how to use in C# the control <asp:FileUpload ID="InputDoc" runat="server" class="custom-file" AllowMultiple="True" />, but let so allow to colcoar description for each file? Thanks

A set of technologies in the .NET Framework for building web applications and XML web services.
3,412 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,629 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce ( 61,266 Reputation points

    without javascript, the best you can do is an array of text boxes for each description. with a little javascript you could make the textbooks papers baed on the file count. a more common server only solution, is to put the file control in its own form, and auto upload (auto submit with a title javascript). the server would create thumbnails, and temporary store the images, and pre-render the UI with the thumbnail and a textbox.

    a more modern UI, is to select or drag drop the image, and display a thumbnail. a notes input would display by the image. when ready posted to the server. there are many upload libraries to help with this. Older browsers required upload in realtime and having the server create the thumbnail, but this is no longer required, it can all be done on the client via the image file api.

    0 comments No comments

  2. Lan Huang-MSFT 28,836 Reputation points Microsoft Vendor

    Hi @Flórida Araújo ,
    From your description, I'm guessing you want a result similar to the example below.

     protected void Button1_Click(object sender, EventArgs e)  
                string filepath = Server.MapPath("\\Upload");  
                HttpFileCollection uploadedFiles = Request.Files;  
                Span1.Text = string.Empty;  
                for (int i = 0; i < uploadedFiles.Count; i++)  
                    HttpPostedFile userPostedFile = uploadedFiles[i];  
                        if (userPostedFile.ContentLength > 0)  
                            Span1.Text += "<br><u>File #" + (i + 1) + "</u><br>";  
                            Span1.Text += "File Content Type: " + userPostedFile.ContentType + "<br>";  
                            Span1.Text += "File Size: " + userPostedFile.ContentLength + "kb<br>";  
                            Span1.Text += "File Name: " + userPostedFile.FileName + "<br>";  
                            userPostedFile.SaveAs(filepath + "\\" + Path.GetFileName(userPostedFile.FileName));  
                            Span1.Text += "Location where saved: " + filepath + "\\" + Path.GetFileName(userPostedFile.FileName) + "<p>";  
                    catch (Exception Ex)  
                        Span1.Text += "Error: <br>" + Ex.Message;  

    Best regards,
    Lan Huang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments