PHP: Upload files works for images but does not work for PDF files

Asked

Viewed 107 times

0

I’m having a strange problem: my form works for uploading images but does not work for uploading PDF files.

My code is this:

$titulo             = $_POST['txtTitulo'];
$descricao      = $_POST['txtDescricao'];

$extension = pathinfo($_FILES['flFile']['name']);
$extension = ".".$extension['extension'];
$extension != '.';
$file = md5(time().rand()).$extension;
$anexo = 'assets/uploads/'.$file;
move_uploaded_file( $_FILES['flFile']['tmp_name'], $anexo );

$query = "insert into tb_arquivos (id_arquivo, titulo, descricao, anexo)
values (null, '".$titulo."', '".$descricao."', '".$anexo."')";

mysql_query($query) or die (mysql_error());

If I insert an image, everything works perfectly. But if I enter a PDF, I lose all form values (including the $title and $description variables.

Can someone help me?

Thank you very much!!!

1 answer

0


I found that the problem was in the limit to upload files.

As the images I usually upload to the site are smaller than 2MB, the problem never occurred.

To solve this problem I created a . htaccess file at the root of the project with the following content:

php_value upload_max_filesize 1G
php_value post_max_size 1G

Browser other questions tagged

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