Upload PHP does not send certain files

Asked

Viewed 89 times

1

Colleagues.

I’m using the basic means of uploading files, since the extension validation is done alone. Our server is limited to files up to 100MB, but when testing, some files will normally, but a 51MB file won’t. No error, only the page of a Reload and does not send. The code follows below:

$arquivoNome = $_FILES['Arquivos']['name'];
$arquivoTemp = $_FILES['Arquivos']['tmp_name'];

list($arquivo, $extensao) = explode(".",$arquivoNome);
    $codificar = md5(date('h:i').$arquivo).".".$extensao;
    $dirArquivo = "uploads/pdf/";
    $upArquivo = $dirArquivo . basename($codificar);

    if(move_uploaded_file($arquivoTemp, $upArquivo)){
       // Aqui cadastro no banco 
    }

Very strange, because the files are of the same PDF extension, what differentiates is the size. Files with 20MB for example go, but the 50MB will not...

  • See if there are any error messages in the server error log.

  • This message appears: [09-May-2016 12:35:30 UTC] PHP Warning: POST Content-Length of 51662811 bytes Exceeds the limit of 8388608 bytes in Unknown on line 0.... but how strange... we put to 100MB

  • Make sure you have not changed php.ini for the command line instead of php.ini for the web server. Try restarting the server. It is also possible that you have multiple local PHP installations (in this case, see which php.ini is used by the command phpinfo()).

  • We don’t actually have access to php.ini because we’re using a cloud. phpinfo() is upload_max_filesize 100M 100M

  • but on that line is 8MB post_max_size

  • I think it is in this line Rodrigo. I will change and return...

  • 1

    That’s the problem. The sum of the size of all files has to be less than or equal to the size of the POST. Just adjust the directive post_max_size for the same 100M.

  • Right Rodrigo. I’ll change here and return ;)

Show 3 more comments

1 answer

1


When I needed to set the maximum upload limit and did not have access to php.ini I decided to set it up in htacess like this:

<IfModule mod_php5.c>
   php_value upload_max_filesize 100M
   php_value post_max_size 100M
</IfModule>

Here’s a reference to where you can put these settings: http://www.php.net/manual/en/configuration.changes.modes.php

In this case being of the category: PHP_INI_PERDIR, version 5.3 or later.

  • Perfect Gabriel. I was thinking exactly how to change if I can’t get by rsrsrsrs server.... If we can’t, we’ll take advantage of your code....

  • Thanks Gabriel. It worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.