Cloudinary - direct delete , jquery file upload, h

2019-08-30 07:20发布

问题:

I did multiple image upload direct from browser using jquery file upload + cloudinary and I need to build direct delete of uploaded image also. I upload image using this file tag

<input name="file" type="file"
 class="cloudinary-fileupload"
 data-cloudinary-field="image_id[]" 
 data-form-data=" ... html-escaped JSON data ... "
 multiple="multiple >
</input>

after uploading, it creates hidden field like this

<input type="hidden" name="images_id[]"
value="image/upload/v1404930923/image_name">

What I want to do is to make additional attribute on this hidden field every time I upload an image, for example "data-id". I need to delete proper hidden field when I delete file from Cloudinary direct from the browser.

cloudinary documentation - Direct upload file tag

回答1:

Since the hidden field has a value, like: resource_type/type/path#signature, where each is available on the result object of the cloudinarydone handler, you can reconstruct this and traverse the hidden fields and find a matching value, and then add the attribute that you want.