Error during upload

Solved
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:

 <?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

  1. jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830
     
    Hello.
    We need to modify the variables that allow increasing the allowed size for file uploads.

    --
    Best regards,
    Jordane
    0
    1. ScreamFR Posted messages 73 Status Member 3
       
      I haven't set up a variable to limit the size of the uploaded files
      I imagine that I need to do this on my server, but where can I find the configuration document?
      0
    2. jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830 > ScreamFR Posted messages 73 Status Member
       
      You just need to search the internet with the keywords php max upload file size... to find thousands of discussions, tutorials, etc. on the subject.
      0
    3. ScreamFR Posted messages 73 Status Member 3 > jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention  
       
      I was just looking online, but it doesn’t specify where to find the configuration document. I have Plesk for my server, but when I look in PHP settings, there’s nothing related to size.
      0
    4. jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830 > ScreamFR Posted messages 73 Status Member
       
      You can make the changes in the php.ini file
      If you don't have access to it, you can make the changes in the .htaccess file

      If you don't know how to do it, you need to contact your hosting provider's support.
      0
    5. ScreamFR Posted messages 73 Status Member 3 > jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention  
       
      I contacted support, but they told me that the server is a dedicated root and that to change the upload size, I need to go through a script via SSH.
      I looked it up online, but I'm afraid of messing things up ;')

      I don't have permissions for the .htaccess file and the php.ini file doesn't exist.
      0
  2. ScreamFR Posted messages 73 Status Member 3
     
    I found the solution, I increased the upload_max_filesize via SSH.
    0