2

I am using jQuery File Upload plugin (http://blueimp.github.io/jQuery-File-Upload/) for image upload for my website.

I want to add image from URL, when user add in textbox.

1
  • 1
    I found for add image to plugin, you must use function 'add' and for use it with image use like '$('#fileupload').fileupload('add', {files: [blob]})' but for use it with URL address, how can I use it Commented Dec 9, 2015 at 11:41

2 Answers 2

2

You have to find a way to download the image from the URL, convert the img into any Type supported by the blob constructor, build a blob file, and call the jQuery File Upload add method like $('#fileupload').fileupload('add', {files: blob})', all grammatically with javascript.

Check this out: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob and this http://qnimate.com/javascript-create-file-object-from-url/

If you manage to implement it, please post here.

Sign up to request clarification or add additional context in comments.

Comments

1

Try something like this

var blob = null;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://path/to/image');
xhr.responseType = 'blob';
xhr.onload = function()
{
   blob = xhr.response;
   $('#mediafile-file-fileupload').fileupload('add', {files: [blob]})
}
xhr.send();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.