Search code examples
phpdropzone.jsmultifile-uploader

Dropzone.js & php file uploading


Please help me i'm tring to create file uploading with dropzone.js and php but when i try to upload large files like 4mb or more my script doesn't work but in case with small files it's worked prefect why?? that is my code

index.php

<!DOCTYPE html>
<html>
  <head> 
    <link href="dropzone.css" type="text/css" rel="stylesheet" />
  </head>
  <body>
    <form action="upload.php" class="dropzone" id="myAwesomeDropzone">
    </form>

    <script src="dropzone.js"></script>
    <script>
        Dropzone.options.myAwesomeDropzone = {
          maxFilesize: 2500000000, // MB
        };
    </script>
  </body>
</html>

upload.php

<?php  

    $ds = DIRECTORY_SEPARATOR;
    $foldername = "./uploads";

    if (!empty($_FILES)) {
        $fileupload = basename( $_FILES['file']['name']);
        $fileType = $_FILES['file']['type'];
        $fileSize = $_FILES['file']['size'];

        $tempFile = $_FILES['file']['tmp_name'];
        $targetPath = dirname( __FILE__ ) . $ds. $foldername . $ds;
        $targetFile =  $targetPath. $fileupload;
        move_uploaded_file($tempFile,$targetFile);
    }
?>

I changed my php.ini file but no success :(


Solution

  • This sounds like a bad server config. Changing your php.ini might not be enough since normally there is a system wide limitation. Depending on your server (eg.: apache) you have to lookup the corresponding settings.