Error during upload
Solved
ScreamFR
Posted messages
73
Status
Member
-
ScreamFR Posted messages 73 Status Member -
ScreamFR Posted messages 73 Status Member -
Hello, I have a problem with document upload in PHP
When I upload a small document (not heavy) it uploads without any problem but when I exceed 1000 KB an error occurs.
Image of the error:
My code:
I don't know what to do ;')
When I upload a small document (not heavy) it uploads without any problem but when I exceed 1000 KB an error occurs.
Image of the error:
My code:
<?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); require_once 'config.php'; $email_bilan = $_POST['email_bilan']; if ($_POST['date_bilan'] == "") { $date_j = date('d'); $date_m = date('m'); $date_a = date('Y'); $dte = date('d/m/Y'); }else{ $date_j = "1"; $date_m = "12"; $date_a = $_POST['date_bilan']; $dte = ''.$date_j.'/'.$date_m.'/'.$date_a.''; } $id_session = $_GET['num']; if (is_uploaded_file($_FILES['doc_files']['tmp_name'])) { echo "File ". $_FILES['doc_files']['name'] ." uploaded successfully.\n"; $dir = '../../../../src/bilan/'; if(!is_dir($dir)){ echo " The destination folder does not exist!"; exit(); } $name_files = $_FILES['doc_files']['name']; $date_now = '-'.date("H-i-s"); $type_files = "." . strtolower(substr(strrchr($name_files, '.'), 1)); $target_file = $_FILES['doc_files']['tmp_name']; $real_name = substr($name_files, 0, -4); $file_name = $dir. $real_name . $date_now . $type_files; if($resultat = move_uploaded_file($target_file, $file_name)){ $insert = $bdd->prepare('INSERT INTO bilan (email_bilan , dte, date_j, date_m, date_a, files_bilan, id_session) VALUES(?,?,?,?,?,?,?)'); $insert->execute(array( htmlspecialchars($email_bilan), htmlspecialchars($dte), htmlspecialchars($date_j), htmlspecialchars($date_m), htmlspecialchars($date_a), htmlspecialchars($real_name . $date_now . $type_files), htmlspecialchars($id_session) )); header('Location: ../bilan-view.php?num='.$_GET['num'].'&time='.$_GET['time'].''); exit(); }else{ echo "Error while moving the file!"; exit; } } else { echo "Error during file upload: "; echo "File name: '". $_FILES['doc_files']['tmp_name'] . "'."; } ?> I don't know what to do ;')
3 answers
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
Hello,
I would check$_FILES['doc_files']['error']
, then react accordingly: https://www.php.net/manual/en/features.file-upload.errors.php -
Hello.
We need to modify the variables that allow increasing the allowed size for file uploads.
--
Best regards,
Jordane -
I found the solution, I increased the upload_max_filesize via SSH.