0

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 ;))

gilm
  • 7,690
  • 3
  • 41
  • 41
  • Do you need this for one file, or multiple files? Would limiting yourself to one file be an option? Where will the file come from, a form? – Pekka Oct 27 '10 at 09:20

3 Answers3

0

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

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

Sasha
  • 544
  • 7
  • 5
  • This is not what he means: He wants file uploads to work without temporary files. – Pekka Oct 27 '10 at 09:21
  • 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 Oct 27 '10 at 09:24
0

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
  • 15,015
  • 8
  • 54
  • 79
  • 1
    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 Oct 27 '10 at 09:30
  • I know and I was just stating the obvious and at the same time adding an idea. – Repox Oct 27 '10 at 09:40
0

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
  • 356,200
  • 43
  • 426
  • 500