PHP usually uses {code...} to process file uploads, and names the temporary files uploaded to the server to the specified directory. Is there a way for PHP to directly write the uploaded file stream to the memory, instead of generating a temporary file on the disk first? (I am doing this because the program running loop... PHP is usually used to process file uploads.
move_uploaded_file( $file['tmp_name'], $new_file )
Name the temporary file uploaded to the server to the specified directory.
Is there a way for PHP to directly write the uploaded file stream to the memory, instead of generating a temporary file on the disk first? (I am doing this because the program running environment does not allow local disk writing)
Reply content:
PHP is usually used to process file uploads.
move_uploaded_file( $file['tmp_name'], $new_file )
Name the temporary file uploaded to the server to the specified directory.
Is there a way for PHP to directly write the uploaded file stream to the memory, instead of generating a temporary file on the disk first? (I am doing this because the program running environment does not allow local disk writing)
Change the source code and re-compile the code ..
You can specify the File Upload path by setting upload_tmp_dir in php. ini. Therefore, you only need to set this path to a memory address. For linux, you can use/dev/shm, and for windows, you can use software such as RamDisk.
Directly use the/dev/shm device, which is the memory. Half of the memory size.
tmpfs 7.5G 0 7.5G 0% /dev/shm
$memfile = file_get_contents( $file['tmp_name'] );
$ Memfile is the file in the memory... destroy the file after php is executed...
PHP cannot be passed to the memory, which has no choice for PHP.
Http://www.qixing318.com/article/php-upload-pictures-rename-6-kinds-of-schemes.html
Six Methods for renaming uploaded images in PHP