Get the App
SLTechnology News&Howtos  ›  Development  › 

What about the rename error in php?

Shulou Source: shulou.com Published: 2022-06-03 15:52:08 10月16日 Update

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!

Tags: Errors content what to do articles security value interests methods reasons guys partners situation reports more best knowledge industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei MariaDB Apple vpn