Solution to the 500 error when uploading files in php: First check the error log and modify the error; then check the permission issue of "client_body_temp" and modify it.
Recommended: "PHP Video Tutorial"
500 error occurred when uploading files in php
Can upload files smaller than 10k, but uploading files larger than 10k will report a 500 error
Solution:
First check the error log and see What is the error
Secondly check the permission issue of client_body_temp
Enter the command nginx -V under linux to see which directory your client_body_temp is in
Pay attention to the user and directory where nginx is running Permissions, including parent directory permissions, must be sufficient; otherwise, a 500 error will occur
Regarding the role of the client_body_temp directory, simply put, if the client POSTs a relatively large file, and the length exceeds the size of the nginx buffer, it is required Temporarily save part or all of the contents of this file to a temporary file in the client_body_temp directory.
Check steps
client_body_temp Is it set to inaccessible, so that there is no permission to write temporary files, resulting in an error 500 This is to check the directory permissions
client_body_buffer_size Is it Use the default settings, 8k or 16k, and the file size exceeds this value, resulting in an error 500. This is to check the nginx.conf configuration
client_header_buffer_size is set to a larger value. This is to check the nginx.conf configuration
The above is the detailed content of What should I do if a 500 error occurs when uploading files in PHP?. For more information, please follow other related articles on the PHP Chinese website!