I would like to upload a file from an html form, post it to PHP and load it into memory, bypassing writing it to a file. Is it possible to do a file upload and keep it in memory, or do I have to write it to a file?
By changing the upload_max_filesize limit in the php. ini file. By implementing file chunk upload, that splits the upload into smaller pieces an assembling these pieces when the upload is completed.
The filesize() function in PHP is an inbuilt function which is used to return the size of a specified file. The filesize() function accepts the filename as a parameter and returns the size of a file in bytes on success and False on failure.
Get the file extension using pathinfo() function in PHP and validate the file format to check whether the user selects an image file. Upload image to server using move_uploaded_file() function in PHP. Insert image file name in the MySQL database using PHP. Upload status will be shown to the user.
The PUT option is cool. If you wanted to use POST and $_FILES, I think the closest you could get would be to point upload_tmp_dir
at a ramdisk.
I do not think this is possible now. You can not use php://input with enctype="multipart/form-data", so that rules out opening the file from a stream. If you go the post route, you only can use the $_FILE variable, which does not contain any binary data, just the pointer to the file on disk.
It looks like xforms will help (http://www.ibm.com/developerworks/xml/library/x-xformstipuploadphp/index.html) but this is in even Firefox 3.5. It requires a plug-in, which is a deal killer for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With