tags:

views:

41

answers:

4

Is it possible in PHP to configure it to somehow not save files to disk at all? As a matter of fact, the best thing would be to get the script going before even reading the entire POST body. (Keeping my hopes high ;))

A: 

You can turn off file uploads via a configuration setting in PHP.

http://php.net/manual/en/ini.core.php#ini.file-uploads

Sasha
This is not what he means: He wants file uploads to work without temporary files.
Pekka
it is even worse. he wants to directly catch the upload stream without buffering it into the tempfile. would be pretty nice for verry big fileuploads.
ITroubs
A: 

take a look to that similar question here:

http://stackoverflow.com/questions/2693529/read-file-as-its-being-uploaded

ITroubs
A: 

PHP needs a place to temporarily store the files content for you to be able to interact with it through PHP - although, you don't have to do anything else other then access the temporary file to get the data:

$content = file_get_contents($_FILES["user_file"]["tmp_name"]);

From here on you can manipulate with the files content without having to move the uploaded file to another location before accessing it.

Repox
that's exactly what he was not asking for. he want's to know if there is a possebility of NOT doing it the normal "save it into a temp then let php work with it" way
ITroubs
I know and I was just stating the obvious and at the same time adding an idea.
Repox
A: 

You can use HTTP PUT requests to directly upload a file. PHP will not handle the upload directly (e.g. set it up in $_FILES). Instead, you have to read the raw bytes from the php://input pseudo-url and from there can do whatever you want.

There's some details and examples here.

Marc B