views:

1191

answers:

3

I'm after a cross-platform cross-browser way of uploading files such that there is no timeout. Uploads aren't necessarily huge -- some just take a long time to upload because of the uploader's slow connection -- but the server times out anyway.

I hear that there are methods to upload files in chunks so that somehow the server decides not to timeout the upload. After searching around all I can see is proprietary upload helpers and Java and Flash (SWFUpload) widgets that aren't cross-platform, don't upload in chunks, or aren't free.

I'd like a way to do it in any of these platforms (ASP, ASP.NET 2.0 or PHP5), though I am not very clued up on all this .NET class/controller/project/module/visual studio/compile/etc stuff, so some kind of runnable complete project that runs on .NET 2.0 would be helpful. PHP and ASP I can assume will be more straight-forward.

Unless I am completely missing something, which I suspect/hope I am, reasonable web uploads are bloody hard work in any language or platform.

So my question is: how can I perform web browser uploads, cross-platform, so that they don't timeout, using free software? Is it possible at all?

A: 

Perhaps you can look at the source of Wordpress? They have both a "standard" file uploader and a flash file uploader.

That said, writing something that chunks something up in smaller bits and later puts it back together is bloody hard work.

A ducttape solution would be to rar it up in smaller bits, upload those bits and unpack it on the server.

knight666
+2  A: 

I imagine the solution that you are really looking for is to gain more control over the server. IIS for example has a timeout setting in addition to any setting you provide in web.config or your php.ini. If php is running in fast cgi then you also have fast cgi configuration.

You can then set relevant file size, memory and timeout settings in php.ini / web.config:

php.ini - http://www.radinks.com/upload/config.php

web.config - httpRuntime executionTimeout="1000" maxRequestLength="400000"

Asp.net provides the possibility to create html modules which provide some of the slicker (asp.net) upload controls, such as multiple uploads, straight to disk (less server memory usage) and upload progress controls, most of these are commercial though.

+1  A: 

No matter what language will deal with the file after the upload is complete, the actual upload is handled by the HTTP server (Apache, IIS, etc.). The way I've seen 'progress bars' or other graphical uploads done in Flash is that there is an AJAX call made to a second script that uploads the file (which locks that thread until the upload is done), and the first script checks the file size of the incoming temporary file for a percentage done.

If you're getting server timeouts while uploading, the issue is likely with your HTTP server (Apache/IIS) configuration, and not holding the connection open log enough. If you tried to set up a PHP file upload system and were getting PHP error messages, likely the 'upload_max_filesize', 'memory_limit', or 'post_max_size' is set incorrectly in your PHP.ini (see PHP's post on file upload pitfals).

MidnightLightning