Search code examples
phpfile-uploaderror-handlingphp-5.3

Getting Content of PHP file upload error


I am working with the move_uploaded_file() function in PHP. I've managed to successfully troubleshoot a problem I was encountering, but I would like to be able to get the actual content of the warnning or error message. According to php.net (http://php.net/manual/en/function.move-uploaded-file.php) the move_uploaded_file() function returns FALSE and a warning on failure. I want the actual content of the warning, such as "failed to open stream: Permission denied..." so that I can record which errors are occurring. Is there a way to do this?


Solution

  • You can do using this: $_FILES['userfile']['error']

    More info: http://php.net/manual/en/features.file-upload.errors.php