How to upload multiple files to a record of a SQL server table from VB.NET and ASP.NET


Currently I have an ASP application where I make certain information records, to this record I attach a PDF file, for that I store the file in a folder within my project and save the path in my bd.

My question is, in the case that I want to add more files that I have to do, my idea was to add more fields in my bd table for files, but again I would have to limit the number of files. What other method would you recommend, and how to use that method.

PS: I would also like to learn how to use JQuery's Multiple file uploader, to perform this action.

asked by Danitza Ayala 12.09.2016 в 18:00

1 answer


Welcome to SOes: D your question has 2 parts:

  • The use of and jQuery File Uploader for uploading files.
  • The architecture at the database level for managing files.

I help you with the database: D I recommend you do the following:

Add a pair of tables called: Archivos and EnlaceArchivosRegistros (* consider that the word Registros refers to the other table you have storing the data)

The relationship of these tables is:

  • A Archivo has one or many EnlaceArchivosRegistros
  • A Registro has one or many EnlaceArchivosRegistros

The EnlaceArchivosRegistros table contains basically (as a recommendation):

  • Unique ID.
  • File ID.
  • Registry ID.
  • Creation date.
  • Data of the user who created it.

The Archivos table will have:

  • ID
  • File name
  • Extension
  • Physical path where it is
  • Date and time of creation
  • User who created it

With this, your business logic remains almost intact: the difference lies in instead of passing the file directly, now save it in another table and if you have many more files to upload, you add them to Archivos and create a new record in the table EnlaceArchivosRegistros .

Please note that to complete this suggestion, you must migrate the document routes of the table you have running and create the relationships with the EnlaceArchivosRegistros table.

The query will change when you want to show the information, since you will need to include 2 more tables, also in the view you will have to do for or% foreach to visualize all the data obtained from the list of linked files.

I hope you have let me understand, any questions / questions you have, add a comment that we all learn: D

answered by 12.09.2016 в 18:51