1
votes

I want to upload the file to my local server, but only small size files worked, if the file size exceeds certain value, then it can not find the uploaded file.

if (isset($_FILES["fileToUpload"]["tmp_name"])) {
  $fileUploaded = move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "./uploads/".$_FILES["fileToUpload"]["name"]);
} else {
  die("Error uploading file.  Please contact an administrator");
} 

Then I changed the upload_max_filesize and post_max_size in php.ini, restart apache, but the problem still exists, couls you help me on that? thanks so much.

update: 1. only one file will be uploaded. 2. Small-size file like less than 2 MB could be uploaded successfully. I tested an 10 MB file, it failed. 3. I changed the two parameters upload_max_filesize and post_max_size from 2 MB to 100 MB.

1
have you checked file_uploads, upload_max_filesize, upload_tmp_dir, post_max_size and max_input_time directives in php.ini? is form set to multivalue/enctype?Rafael
I mean is the form set to enctype="multipart/form-data"?Rafael
You can use phpinfo to check the path to the php.ini that is being used, you can also check the max sizes in there to see if they are being set properlyZach
There are often 2 php.ini files. One used by PHP CLI and one used by the PHP that is part of Apache. I would guess you have edited the wrong one. You dont mention you OS so its difficult to be more specific than thatRiggsFolly
@RafaelI set the form to enctype="multipart/form-data". I just change the upload_max_filesize, post_max_size, others are left default.Wen Zhu

1 Answers

0
votes

So you can see what actual error is being generated try this code

if ( isset($_FILES["fileToUpload"]) ) {
    print_r($_FILES);
}

Then look at the [error] array and see what error is actually being reported.

Then check this page in the manual to see what the numbers mean.