I want to make image upload from url for example: http://.. ../logo.png I need to make formData object from image url but it doesn't work:
HTML:
<form id="form-url">
    <input type="text" class="image" id="textarea" placeholder="URL" />
    <button>UPLOAD</button>
</form>
Javascript:
$("#form-url").submit(function(e) {
        if ($(".image").val() != "URL" && $(".image").val() != "") {
            //I also tried this:
            var data;
            var img = new Image();
            img.src = $(".image").val();
            img.load = function(){
                data = getBase64Image($(".image").val());
            };
            //but it send undefined
            //and this:
            var data = URL.createObjectURL($(".image").val()); //dont work
            //error: TypeError: Argument 1 is not valid for any of the 1-argument overloads of URL.createObjectURL.
               //Upload process working on normal input type file uploading but no on URL image
            var formData = new FormData(data);
            formData.append("fileToUpload", data);
            var xhr = new XMLHttpRequest();
            xhr.open('POST', "upload_ajax.php", true);
            xhr.onload = function () {
              if (xhr.status === 200) {
                data = xhr.responseText;
                datas = data.split("_");
                if (datas[0] != "true") {
                    alert(data);
                } else {
                    alert('YES');
                }
              } else {
                alerter('An error occurred while uploading this file! Try it again.');
              }
            };
            xhr.send(formData);
        } else { alerter("Your file must be an image!"); }
        return false;
    });
My php script for debug:
<?php
    if (isset($_POST)) {
        var_dump($_POST);
        if (empty($_FILES['fileToUpload']['tmp_name'])) {
            echo "Your file must be an image!";
        } else {
            echo $_FILES['fileToUpload']['name'];
            echo $_FILES['fileToUpload']['size'];
        }
    }
?>
Thanks for all help and your time.. and sorry for my bad english (student)
 
     
    