Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to upload a file via an HTTP POST with a web form?

Basically, something better than this:

<input type="file" name="myfile" size="50">

First of all, the browse button looks different on every browser. Unlike the submit button on a form, you have to come up with some hack-y way to style it.

Secondly, there's no progress indicator showing you how much of the file has uploaded. You usually have to implement some kind of client-side way to disable multiple submits (e.g. change the submit button to a disabled button showing "Form submitting... please wait.") or flash a giant warning.

Are there any good solutions to this that don't use Flash or Java?

Yaakov: That product looks to be exactly what I'm looking for, but the cost is $1000 and its specifically for ASP.NET. Are there any open source projects that cover the same or similar functionality?

like image 578
go minimal Avatar asked Aug 15 '08 04:08

go minimal


People also ask

What HTTP method is used to upload files?

HTTP Request action allows you to upload files on a specified service.

What's the best way to upload files from the Web?

FTP Programs The most popular way to publish files to the web is by using an FTP (file transfer protocol) program. These programs create a link between your computer and the server that hosts your account, allowing you to copy and paste (or click and drag) your website files to your HostPapa hosting space.

Can you send files over HTTP?

An HTTP file transfer is the process of transferring a file between multiple nodes/devices using the HTTP protocol, or more generally, the Internet. It is one of the most commonly used methods for sending, receiving or exchanging data and files over the Internet or a TCP/IP-based network.


2 Answers

File upload boxes is where we're currently at if you don't want to involve other technologies like Flash, Java or ActiveX.

With plain HTML you are pretty much limited to the experience you've described (no progress bar, double submits, etc). If you are willing to use some javascript, you can solve some of the problems by giving feedback that the upload is in progress and even showing the upload progress (it is a hack because you shouldn't have to do a full round-trip to the server and back, but at least it works).

If you are willing to use Flash (which is available pretty much anywhere and on many platforms), you can overcome pretty much all of these problems. A quick googling turned up two such components, both of them free and open source. I never used any of them, but they look good. BTW, Flash isn't without its problems either, for example when using the multi-file uploader for slide share, the browser kept constantly crashing on me :-(

Probably the best solution currently is to detect dynamically if the user has Flash, and if it's the case, give her the flash version of the uploader, while still making it possible to choose the basic HTML one.

HTH

like image 129
Grey Panther Avatar answered Sep 30 '22 15:09

Grey Panther


You could have a look at the Fancy Upload script. Though it uses flash it still looks great.

like image 22
DylanJ Avatar answered Sep 30 '22 15:09

DylanJ