-1

I want to make a feature on a website from which anyone can upload an image from desktop into a server get a link.

Like used in https://stackoverflow.com where it is uploaded and the link is pasted.

I want the link.

Is there any way to work on it?

mrityi
  • 1
  • 1
  • 1
    Do you have any code? Ofcourse there are alot of ways to do this, you have to be more specific in your question. – DoobyScooby Oct 18 '18 at 22:11
  • Possible duplicate of [JavaScript: Upload file](https://stackoverflow.com/questions/5587973/javascript-upload-file) – helb Oct 18 '18 at 22:51

1 Answers1

0

You can use Ospry.io - here is a usage example:

<script src="https://code.ospry.io/v1/ospry.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>

<form id="up-form">
    <input type="file" multiple />
    <button type="submit">Upload image</button>
</form>

<script>
    var ospry = new Ospry('YOUR_PUBLIC_KEY');

    $('#up-form').submit(function(e) {
        e.preventDefault();
        ospry.up({
            form: this,
            imageReady: function(err, metadata, i) {
                alert("Find file at: " + metadata.url);
            }
        });
    });
</script>

P.S. - you need to sign up to get your API key.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79