Home >Backend Development >PHP Tutorial >Two errors caused by php.ini configuration errors: ajax image upload error and exec error, _PHP tutorial
Encountered two errors caused by php.ini configuration errors: ajax Image upload error and exec error
First one:
While making an ajax image upload function, PHP reported such an error: File upload error - unable to create a temporary file;
Then Baidu checked and found that the configuration of upload_tmp_dir in the php.ini configuration file was not handled properly.
So Baidu posted this: For reference
1. Because there is no uploaded temporary file set in php.ini, the default is the system's temporary file address.
2. If you do not have permission to read the system's temporary file directory, the above error will occur.
The solution is to remove the semicolon in front of upload_tmp_dir and set the temporary file directory.
3. If it is a WIN system, all parent folders of the set temporary folder must have the "List folder directory" permission of "IUSR_***** (Internet guest account)". It is recommended to create this temporary folder in PHP directory.
Second: When compressing the front-end css file today, I found that it could not be compressed. The program and permissions were correct. Then I checked and found that it was due to the disable_function configuration in php.ini that caused an error when executing exec compression!
For security reasons, the server does not allow php or other languages to execute exec commands. When you have special needs for php to execute exec commands on the server, you need to set two places, otherwise the execution will not be successful
1. Modify php.ini
Find the php configuration file php.ini. If you use the extraterrestrial php automatic installation program to configure the php environment, this file is in the C:WINDOWS directory.
Search for "disable_functions" in the file, find it, remove "exec" and "shell_exec", and then save the file.
2. Modify cmd.exe file properties
Enter C:WINDOWSsystem32, find the file cmd.exe, right-click -> Properties, add the Internet guest account in the "Security" settings, that is, the IUSR_****** account, and then assign "Read and "Run" and "Read" permissions.
After this setting is completed, php can execute the exec command on the server.