I am implementing uploading images, photos using the imgur
.
So far I have developed the dropzone option, which allows me to drag or click the Dropzone to upload/upload images and save them to imgur
and not my local hosting.
Through my upload.js code.
var feedback = function(res) {
if (res.success === true) {
var get_link = res.data.link.replace(/^http:\/\//i, 'https://');
document.querySelector('.status').classList.add('bg-success');
document.querySelector('.status').innerHTML =
'Image : ' + '<br><input class="image-url" value=\"' + get_link + '\"/>' + '<img class="img" alt="Imgur-Upload" src=\"' + get_link + '\"/>';
}
};
new Imgur({
clientid: '', //You can change this ClientID
callback: feedback
});
And from a simple structure of HTML
.
<body>
<div class="title">
<h1>Imgur Upload API</h1>
<p>Use JavaScript To Upload Image</p>
</div>
<div class="dropzone">
<div class="info"></div>
</div>
<script type="text/javascript" src="./js/imgur.js"></script>
<script type="text/javascript" src="./js/upload.js"></script>
</body>
I get my dropzone
that allows me to upload/upload the images to hosting imgur
.
I have added the following lines to the imgur.jsfd.append('type', 'URL');
code .
var fd = new FormData();
fd.append('image', file);
fd.append('type', 'URL');
But how can you add the option to enter an image url and upload/upload save to imgur?
I want to add both options in my dropzone, upload images locally and use an image url.
The same StackOverflow system, which allows drag image/select image and at the same time allows uploading images from an example image URL: