Asked by:
Upload Function ASP.NET C#

Question
-
User-1901014284 posted
Hi,
I am looking to implement an upload function to allow single and multiple file uploads. I would also like to be able to add information about the document into a database so I can later use a GridView so that users will be able to display, search and open the documents. Documents are also going to be split into categories which can be selected via a dropdown list stored within the DB As there will be multiple clients using this function I would also like the document to be saved into a folder in the back end of my server using the Client ID within the saving of the document so all client documents are placed within the correct client folder.
Many thanks for any assistance provided in advance.
Jonny
Friday, March 29, 2019 12:48 PM
All replies
-
User475983607 posted
This is standard ASP.NET Web Forms. Drop server controls on the markup and add a submit button. Process the inputs in the submit button click handler.
Is there any way you can share your code and explain what problem you are facing? Otherwise; if you're not sure how to build a Web Forms application, I recommend that you step through a few tutorials first.
File Upload Control.
Web Forms tutorials.
https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/
Friday, March 29, 2019 2:00 PM -
User-893317190 posted
Hi jonnygareth30 ,
If you want to upload multiple files, you could use AllowMutiple property of the fileupload control.
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
Then you could get the files through Request.Files property.
HttpFileCollection _HttpFileCollection = Request.Files; for (int i = 0; i < _HttpFileCollection.Count; i++) { HttpPostedFile _HttpPostedFile = _HttpFileCollection[i]; if (_HttpPostedFile.ContentLength > 0) { // please write whatever filename you like _HttpPostedFile.SaveAs(Server.MapPath("~/images/small/" + Path.GetFileName(_HttpPostedFile.FileName))); } }
About how to combine gridview with fileupload, please refer to
About categories, you could add a category table and let your document table refer to category table.
For example , you document table is as follows
document id int docname nvarchar docpath nvarchar cat_id int
Then your category table could be
category cat_id int catname nvarchar
You could bind your downdownlist with data in category and select doc whose category is the category selected in the dropdownlist.
Best regards,
Ackerly Xu
Monday, April 1, 2019 8:17 AM -
User-2054057000 posted
Basically you need to implement the Multiple File Upload feature in your website. There are many good JavaScript plugins to do it. One such is BlueImp plugin in GitHub.
Otherwise if you want to implement this feature by your own then you should look into the below 2 tutorials:
1. Create Multiple File Upload feature with Progress Bar
2. Upload Multiple files using jQuery AJAX
Regards.
Tuesday, April 2, 2019 5:51 AM -
User1052662409 posted
this may help you
Wednesday, April 17, 2019 10:26 AM