Advise me the most optimal way to save large files from php stdin, please. iOS developer sends me large video content to server and i have to store it in to files.
I read the stdin thread with video data and write it to the file. For example, in this way:
$handle = fopen("php://input", "rb");
while (!feof($handle)) {
$http_raw_post_data .= fread($handle, 8192);
}
What function is better to use? file_get_contents or fread or something else?
If you use nginx as web server i want to recommend nginx upload module with possibility to resume upload.
Don't use
file_get_contents
because it would attempt to load all the content of the file into a stringFROM PHP DOC
Am sure you just want to create the movie file on your server .. this is a more efficient way
I agree with @hek2mgl that treating this as a multipart form upload would make most sense, but if you can't alter your input interface then you can use
file_put_contents()
on a stream instead of looping through the file yourself.It's cleaner than iterating through the file, and it might be faster (I haven't tested).