Introduction
The ability to upload files is a key requirement for many web and mobile applications. From uploading your photo on social ...
For further actions, you may consider blocking this person and/or reporting abuse
Something to note about the progress bar example is that it may not finish for users who have fast connections. I was testing it out and noticed that a
progress
event was fired around the 1% mark for a couple of files, but wasn't fired again beforereadyState
indicated that the file upload was done. For a production implementation, you'll probably also want to hook into theloadend
event to account for this. Here's a slightly modified version of the above example that demonstrates this:Great point Payton! I am gonna look into that and modify. Thanks for reading and commenting.
What specifies the domain of the Object URLs? In the embedded CodePen example #10, the URL ends up something like
blob:https://cdpn.io/5a61e13d-0c89-490c-8cce-d6bf06483b9b
. Not understanding how it came up with cdpn.ioHey Daniel, thanks for mentioning that. The object url doesn't mention any domain for this example. It is just expected to get the image converted for this example.
I have rechecked and found it working when I upload an image. Could you please elaborate the steps to get the problem mentioned? I am interested to know that and check.
Hi Tapas, I was just examining the src attribute of the image in the iframe after the image was uploaded.
I figured out why I was confused though. In your post, the CodePen iframe has the src value
https://codepen.io/atapas/embed/BazzaoN?height=600&default-tab=result&embed-version=2
. But I didn't notice last time that there was a sub-iframe that CodePen put in with src valuehttps://cdpn.io/atapas/fullembedgrid/BazzaoN?animations=run&type=embed
. So it seems like the blob URL is just based on the URL of the page or frame that the JS is running in.Seems kind of weird that the browser adds the domain in when the blob is local to you machine only anyway
Sure, thanks Daniel.
This is very interesting but a true upload would write the file out to a server, with all the complexities that involves. File name rules, permissions, paths, umasks etc. Using this code what have we actually uploaded to? The browser’s memory?
Yes John, you are right.
The scope of the article was to introduce the basics and focusing on the Html file upload tag and client side file object.
I am writing a series now to build on top of it to showcase with server side pieces using Node.js. Hoping that will get you what you are asking for. Please stay tuned.
Thanks for reading and commenting!
Thank you so much for the explanation.
Thank you very much.. Glad it was useful!
Great, thanks for sharing!
Thank you!
Think this is the best HTML article ive read.
Yaay... That's huge! Thank you very much.
Wonderful article!
Thank you very much!
Thanks a lot for this. Best article I've read today
Thank you Mateen!
Learned a lot! Thanks
Thank you Natnael. Very glad as it was useful to you!
Good article. Thank you 🙂👍
Thank you, Brian!
Thank you very much
Great artical, Thanks so much :)
Thank you for reading and liking!
Very useful post, 😄
Glad it was useful, Shaijut.
Heh, file upload has so many weird quirks, especially when dealing with images, i just use Uppy and go on with more important tasks ;)
Thanks so much for this post. I now have a much better understanding of the file upload system.
Wow, Thanks Neelam! Glad it was useful.
good one 👍🏻✨
Thankyou so much! 😇
Thank you!
Thank you for such an amazing tips.
Thanks Maxwell.. Glad it was helpful.
This was quite an insightful read of HTML file upload functionality, even in 2024, this is very valuable! Has anything changed about this over the years?
Thanks Jordan.