A useful way to handle large file uploads is to do something like:
copy(("php://input"),$tmpfile);
as this avoids using lots of memory just to buffer the file content.
The correct mime type for this should be "application/octet-stream" however if you set this or any other recognised mime type other than "multipart/form-data" on your POST then $HTTP_RAW_POST_DATA is populated and the memory is consumed anyway.
Setting the mime type to "multipart/form-data" raises “PHP Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0” however it seems to work without a problem.