This upload is optional. If other fields, including the form, are sent in PUT mode, how can we determine whether a file is uploaded? My current solution is to read the PUT file and merge it into a temporary file, and then use fiesize to determine the file size... this upload is optional. If other fields, including the form, are sent in PUT mode, how can we determine whether a file is uploaded?
My current solution is to read the PUT file and merge it into a temporary file, and then use fiesize to determine the size of the file. If it is 0, it indicates that the file is not uploaded, but it is not safe to do so, for more information, see.
$ Handle = fopen ('php: // input', 'R'); $ fp = fopen ($ tmp_as, "w + "); while ($ data = fread ($ handle, 1024) {fwrite ($ fp, $ data) ;}fclose ($ fp); fclose ($ handle ); if (filesize ($ tmp_as) & getimagesize ($ tmp_as) {// The file is an image, therefore, the getimagesize function echo '// TODO has file upload and processing';} else {echo 'No file upload ';}
Reply content:
This upload is optional. If other fields, including the form, are sent in PUT mode, how can we determine whether a file is uploaded?
My current solution is to read the PUT file and merge it into a temporary file, and then use fiesize to determine the size of the file. If it is 0, it indicates that the file is not uploaded, but it is not safe to do so, for more information, see.
$ Handle = fopen ('php: // input', 'R'); $ fp = fopen ($ tmp_as, "w + "); while ($ data = fread ($ handle, 1024) {fwrite ($ fp, $ data) ;}fclose ($ fp); fclose ($ handle ); if (filesize ($ tmp_as) & getimagesize ($ tmp_as) {// The file is an image, therefore, the getimagesize function echo '// TODO has file upload and processing';} else {echo 'No file upload ';}
After the form is submitted, Print $ _ FILES ['myfile']. This is the uploaded image (temporary file ending with tmp). You need to move the file and use the move_uploaded_file function.