Monday 15 March 2021

How to get a URL from server and convert it into a valid Dropzone.js file object?

I've just been trying to figure out how to get a file URL from the server and display it as an image in dropzone. The problem I have is I have no idea how to convert that URL into a dropzone file object. I've checked out this, and I get the idea, but the explanation isn't that clear.

Here is my code:

$('.c-section').on('click', '.s-body-row', async function () {  
  // AJAX stuff
  let file = res.data.file
  // File syntax is { name: smthng, url: smthng }
  upDropzone.emit("addedfile", { name: file.name }) // error is here
  upDropzone.emit("thumbnail", { name: file.name }, file.url) // This does not run (obviously)
})

Any help is greatly appreciated!

Thanks in advance!



from How to get a URL from server and convert it into a valid Dropzone.js file object?

No comments:

Post a Comment