【问题标题】:php uploading is not working perfectlyphp上传无法正常工作
【发布时间】:2014-04-03 11:48:04
【问题描述】:

这是(几乎)完美的工作,有些文件已上传,有些则没有(尤其是大文件)。任何想法 ?我以为ini_set('post_max_size', '1024M');ini_set('upload_max_filesize', '1024M'); 可以解决大小问题,但它不能正常工作。

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

【问题讨论】:

  • 您收到什么错误?上传是可写的吗?

标签: php forms post upload uploading


【解决方案1】:

可能是超时或内存限制。您可以尝试在 htaccess 中增加它们

php_value memory_limit 150M
php_value max_execution_time 500

【讨论】:

  • 仍然无法正常工作:/ ini_set('memory_limit','128M'); ini_set('max_execution_time', '3000'); ini_set('post_max_size', '1024M'); ini_set('upload_max_filesize', '1024M');
  • 您收到的错误是什么。可能不是大小,而是文件本身?
【解决方案2】:

尝试增加 php.ini 中的 memory_limit。

您也可以尝试分块上传。见http://www.plupload.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    相关资源
    最近更新 更多