Share your repls and programming experiences

← Back to all posts
Image Uploader
ruiwenge2

Do you need an image uploader that can generate an image URL that isn't extremely long, without reloading the page? Luckily, I've got you covered. I created my own image uploader, and you can use it too. Here's how to use it.

How to use Image Uploader

First, we create the HTML input:

And in the JavaScript code, first we add the event listener:

Next is the uploadFile function, where we will use the fetch method to generate a URL for the file:

If you upload a file that isn't an image, it will give you an error that says TypeError: Failed to fetch.

I hope this was helpful!

Voters
PixiGem
CosmicBear
justaperson22
ruiwenge2
Comments
hotnewtop
williham

is this an app or just a way to do it?

ruiwenge2

@williham what do you mean?

williham

@ruiwenge2 does it actully give a url to images, or just telling people how to do it themselves?

ruiwenge2

@williham this is an image uploader that you can use to generate image URLs, and I show you how to do it in the description

ruiwenge2

@williham it does give a url to images, but you need to add some code to make it work.

ruiwenge2

@williham its explained in the description

williham

@ruiwenge2 ah, well, maybe add the code for the people so you only have to fork and add the url

ruiwenge2

@williham uh what?

williham

@ruiwenge2 well, idk

ruiwenge2

@williham this was made so that you can quickly generate an image url without reloading the page or going to another.

williham
CosmicBear

@williham if it is telling people how to make it themselves, this would be in the tutorial section.