multiple file upload with description asp.net c#

Flórida Araújo 1 Reputation point
2022-05-06T14:18:02.837+00:00

hello,

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

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,412 questions
C#
C#
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 (SqlWork.com) 61,266 Reputation points
    2022-05-06T15:29:45.98+00:00

    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
    2022-05-09T08:23:49.94+00:00

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

     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];  
      
                    try  
                    {  
                        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;  
                    }  
                }  
            }  
    

    200163-demo.gif
    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