Ashok Kumar
Ashok Kumar

Reputation: 43

how to insert form data only once in blueimp jquery multi file uploader

I am using blueimp jQuery multi file uploader. Files are uploading fine also I am able to insert form data into MySQL database. But my problem is I am getting the MySQL query executed every time each file uploads. Suppose I click on the Add Files button and then 5 images listed. Then after clicking on Start Upload button 5 images uploaded to the server also 5 rows in the database. But I need only 1 row in the database. I do not want to loop the MySQL query. Is this possible?

Upvotes: 2

Views: 307

Answers (1)

Ayanlade Olawale
Ayanlade Olawale

Reputation: 21

I know this is an old question but you can't expect the images to all be saved in a single row, each image has to be saved as a unique instance in the Database. Blueimp creates a computed list of the images and sends them one at a time.

However, if you were to send the images without blueimp, you would be getting a list in your request.POST in the backend and if you save that directly into the DB, when you try to make a GET of the object you would only be able to receive one image which is going to be the first image in the list because the DB doesn't save images, it only saves a reference to the path of it and only the first reference gets saved in that scenerio.

Moreover, If you try to find a way to save the images list you have in the backend to the DB, you would have to loop over each iteration of it and save in the DB and that would be a roundtrip of stressing yourself when blueimp already created a solution for that out of the box

Upvotes: 2

Related Questions