0

Files more than 50 KB are not uploading. I have checked php.ini and i have following values

post_max_size = 16M (which i have increased from 3 MB but still no luck)
upload_max_filesize = 64M
max_file_uploads = 20

I've tried and read everything, couldn't find a solution, if anyone has gone thru the same problem, please share your experience.

PHP:

if(isset($_FILES["file"]))
{
    if($_FILES["file"]["error"] == 0)
    {
        $uploaded_file_name =  $_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]['tmp_name'], __DIR__ . "/" . $uploaded_file_name);
        exit;
    }
}

HTML:

<form action="<?php $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="Submit">
</form>
Faizan Shakeel
  • 171
  • 1
  • 16
  • Have you restarted apache since making the change? – Jono20201 Jul 19 '14 at 11:12
  • @Mooseman `ini_set` cannot change upload limits as they are used before the page is processed. (See: http://stackoverflow.com/a/1122443/1392533) – Jono20201 Jul 19 '14 at 11:13
  • If you have restarted apache, post your upload code. It could be setting its own maximum. – Jono20201 Jul 19 '14 at 11:14
  • From Docs: http://php.net/manual/de/function.ini-set.php Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. – Julian F. Weinert Jul 19 '14 at 11:14
  • i restart whenever i change anything i have updated the question with code – Faizan Shakeel Jul 19 '14 at 21:45

1 Answers1

1

The post_max_size must be equal or greater than upload_file_size

Example

 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 64M

 ; Must be greater than or equal to upload_max_filesize  
 post_max_size = 64M
Denzyl Dick
  • 293
  • 3
  • 11