views:

81

answers:

3

I would like to create an upload script that doesn't fall under the php upload limit. There might be an occasion where I need to upload a 2GB, or larger file and I don't want to have to change the whole server execution to above 32MB.

Is there a way to write direct to disk from php?

What method might you propose someone would use to accomplish this? I have read around stack overflow but haven't quite found what I am looking to do.

+1  A: 

It isn't possible to upload a file larger than PHP allowed limits with PHP, it's that simple.

Possible workarounds include using a client-side technology - like Java, not sure if Flash and Javascript can do this - to "split" the original file in smaller chunks.

Alix Axel
+2  A: 

The simple answer is you can't due to the way that apache handles post data.

If you're adamant to have larger file uploads and still use php for the backend you could write a simple file upload receiver using the php sockets api and run it as a standalone service. Some good details to be found at http://devzone.zend.com/article/1086#Heading8

easel
+1  A: 

You can do some interesting things based around PHP's sockets. Have you considered writing an applet in Java to upload the file to a listening PHP daemon? This probably won't work on most professional hosting providers, but if you're running your own server, you could make it work. Consider the following sequence:

  1. Applet starts up, sends a request to PHP to open a listening socket
    1. (You'll probably have to write a basic web browser in Java to make this work)
  2. Java Applet reads the file from the file system and uploads it to PHP through the socket that was created in step 1.

Not the cleanest way to do it, but if you disable the PHP script timeout in your php.ini file, then you could make something work.

Sean Madden