-2

I used this method move_uploaded_file() in my script to upload files..., Sometimes the images and files uploaded Successfully, but sometimes the File upload process fails :( ....Note: the files' size smaller than upload_max_filesize in php.ini of my web host host, So what is the factors or elements that affect on uploading process as upload_max_filesize

IF max_execution_time or memory_limit or ..... affect

  • 2
    Can you provide the code around your usage of move_uploaded_file? Without that its impossible to help you. We dont know what 'sometimes' means here, im assuming youre not programming a random number generator. – Definitely not Rafal Jan 13 '21 at 15:14
  • the code is very well .... I want to know only elements those affect on uploading process as IF "max_execution_time" or "memory_limit" or ..... affect – Medo Elmasri Jan 13 '21 at 17:33
  • My educated guess is that you don't verify the `error` key in `$_FILES` and invoke `move_uploaded_file()` even if the upload failed, thus the seemingly randomly failures. – Álvaro González Jan 13 '21 at 17:50
  • @MedoElmasri why are you asking for help if you are not willing to provide details such as the **actual code which produces this problem?** There could be numerous reasons: permission, file size, space on disc, file name, ... but all of this doesnt matter. Since your code is working, there should be no problem to adjust it to log meta data to the files that it can save and everything it cant save. Then you could try to see a pattern to figure out whats wrong... also make sure you are [displaying errors](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display). – Definitely not Rafal Jan 14 '21 at 07:20

1 Answers1

0

Two of the reasons include:

  1. Trying to write a file in a directory that has no write permission
  2. Invalid file name that contains some special characters

You can also have a look at error_reporting

manqlele
  • 62
  • 10