Question

This is working (almost) perfectly some of the files is uploaded and some don't (espcially huge file). Any idea ? I thought ini_set('post_max_size', '1024M'); and ini_set('upload_max_filesize', '1024M'); would solve the size problem but it's not working properly.

<?php

ini_set('post_max_size', '1024M');
ini_set('upload_max_filesize', '1024M');

if (isset($_FILES["myfile"])) {
    if ($_FILES["myfile"]["error"] > 0) {
        echo "Error: " . $_FILES["file"]["error"] . "<br>";
    } else {

    $target_path = "uploads/";

    if(!file_exists($target_path)){mkdir($target_path);}

        move_uploaded_file($_FILES["myfile"]["tmp_name"], $target_path.$_FILES["myfile"]["name"]);
        echo "<pre>";
        print_r($_POST);
        print_r($_FILES);

    }

}

?><!doctype html>
<head></head>
<body>
   <form action="/" method="post" enctype="multipart/form-data">
    <input type="file" name="myfile">
    <input type="submit" value="Upload">
    </form>
</body>
</html>

No correct solution

OTHER TIPS

It might be time out or memory limit. You can try to increase them in htaccess

php_value memory_limit 150M
php_value max_execution_time 500

Try to increase memory_limit in php.ini.

You can also try to upload in chunks. See http://www.plupload.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top