I try to upload a file with PHP and I use the function "move_uploaded_file()" for it. Everything works well, until I try to upload a zipped CSV file. The file itself is 50MB, but once it is zipped, it's just 3MB. I can upload files until 5MB to the server, so in the case of the zip file, I thought this would work, but it doesn't.
* Uploading a zipped CSV file of 100kb does work,
* I did delete 1/3 of the lines from the CSV file, the CSV file is 28MB, and this I could upload (zipped it was 1.6MB),
* The zipped file of 3MB doesn't appear in the folder on the server. The zipped files of 100KB and 1.6MB do appear there,
* I didn't get an error message, but it does echo "Error uploading!".
Did someone face the same problems, or does someone knows a solution? Let me know! This is basicly my code;
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (isset($_POST["submit"])) {
$file = $_FILES["file"];
$filename = $file["name"];
$target_dir = "data/";
$target_file = $target_dir . basename($filename);
$file_type = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if (move_uploaded_file($file["tmp_name"], $target_file)) {
echo "Done uploading!";
} else {
echo "Error uploading!";
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="custom-file mb-3">
<input type="file" class="custom-file-input" id="file" name="file" required accept=".csv,.zip" />
</div>
<p class="text-right">
<button class="btn btn-primary" name="submit" type="submit">Upload!</button>
</p>
</form>
Let me know if you need something. All the help and ideas are appericiated. Thanks!
Edit;
I did got an error in $_FILES['file']['error'];
I got error "1", which reffers to: 'The uploaded file exceeds the upload_max_filesize directive in php.ini'
https://www.php.net/manual/en/features.file-upload.errors.php
I did "echo phpinfo();", and found out that upload_max_filesize is only 2MB instead of the 5MB that I thought I configurated.