binary file upload using HTTP


I was looking into how to achive a file upload using http. I found an interesting example @ 

As you can see it allows the client to upload a gif file which it displays. I am interested in how this works on the client side. I looked at the source code and could not work it out.

Where is the code telling the browser to open the windows "file open dialog box" and where is the code to perform a URL encode on the data? I assume thats what it does.

I also copied the source and ran it on my local machine, when I did this the "browse" for a file button vanished (I never saw the code for it in the original), where did it come from?

I'm confused.... how does it work?

Also Is there a limit to the file size you can upload?

Thanks, Andy
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

i can atleast help you out with the file dialog showing up .. to get that use something like this <input type=file name=filenm size=20 accept="image/*">

The input form must POST the data and the type is called "multipart-form". You can find a spec of what the server sees (or what the browser sends) by searching for this term and downloading the RFC (whose number escape me for the moment).
   The browser "invents" a sequence of characters which DOES NOT OCCUR in the file data, eg: xvtyfghstegsjshbe. It then sends

<data from the file>

as well as the other (if any) form fields. You in your cgi must separate all this out and recontruct the file.

There is no limit that I have found on uploading. My app uploads files of around 11MB. I do all of this in C without any special objects. VB wraps all this up in objects, of which I have no experience.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
This kind of form uploads files for me with no problem

<form enctype="multipart-form/data" method=POST action="/somepath/upload.asp" name=main>
<input type=file name=TheFile size=50>

In this way browser reads the file, encodes it using MIME encoding and sends to the action URL, where it may be extracted using some COM object, or cgi-script.
andyknottAuthor Commented:
Thanks all of you for your help. Its a shame points can't be divided between several experts.

It was hard to decide who's answer to except. Bigrat gave the general description I required.

Thanks again
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.