Search code examples
phparraysdatabasecloudinary

Cloudinary multiple image uploaded store in on database


I need to store multiple images uploaded on my database in different field in db.

I upload all images and then through POST method I insert data on db. The first image works but second no.

All field of images have name=image.

<input class="cloudinary-hidden-field" type="hidden" name="image" data-cloudinary-public-id="g4002uhktsiqr7ucg8e2" value="image/upload/v1475179093/g4002uhktsiqr7ucg8e2.jpg#b898624e496e9ba9ce936eba7bc72571be3baa52">

Solution

  • You can change the name of the generated hidden fields using the data-cloudinary-field attribute on the file-upload field, e.g.:

    <input name="file" type="file" class="cloudinary-fileupload" data-cloudinary-field="image[]" multiple="multiple" />
    

    When submitting the form, this will result in an array sent over to the server.

    I think this should solve the issue.