What about the rename error in php?
This article mainly introduces how to do rename errors in php. It is very detailed and has a certain reference value. Friends who are interested must finish it!
Print out the cause of the error.
Error_get_last () doesn't seem to return anything. Rename () returns true false instead of an exception.
If (! rename ($file- > filepath, $full_path) {$error = error_get_last (); watchdog ('name', "Failed to move the uploaded file from% source to% dest", array ('% source' = > $file- > filepath,'% dest' = > $full_path));}
Solution.
First of all, it is best to add some security checks before:
If (file_exists ($old_name) & & (! file_exists ($new_name)) | | is_writable ($new_name) {rename ($old_name, $new_name);}
Second, you can turn on error reporting:
Error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); these are all the contents of the article "what to do with rename errors in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!