簡體   English   中英

在IE6中上傳大於10Mb的文件時出現問題

[英]Problem uploading files greater than 10Mb in IE6

嘿。 此代碼可在大多數瀏覽器中使用,甚至在IE6中也可部分使用。 它上傳的文件少於10Mb(大約),但沒有更大的文件。 該代碼指定允許這些文件。

另外,請注意,似乎整個文件似乎已被忽略之前已傳輸到服務器。

該網站位於: www.mgxvideo.com/mgxcopy-alpha-3/ ,可以通過在購物車中添加項目,然后單擊上載功能來訪問。 想法?

形式如下:

<form enctype="multipart/form-data" action="upload_files.php?order_id=<?php echo $_GET['order_id'] ?>" method="POST">
    <table style="width:100%">
        <tr>
            <td valign="top">
                <span class="style1">Choose a file to upload: </span> 
            </td>
            <td valign="top">
                <input name="uploadedfile" type="file" />
            </td>
        </tr>
    </table>
    <input type="submit" value="Upload File" />
    <input type="hidden" name="action" value="add"/>
    <input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
</form>

這是upload_files.php頂部的一行:

$upload_output = upload_file($customer_id, $_REQUEST['action'], $_GET['order_id'], $_FILES);

這是upload_file()代碼:

function upload_file($customer_id, $action, $upload_id, $FILES)
{
    $target_path = "uploads/";

    $target_path = $target_path . $customer_id . '_' . $upload_id . '_' . basename( $FILES['uploadedfile']['name']); 
    $str_output = '';

    if ($action == 'del' and file_exists($_POST['filepath']))
    {
        delete_file($customer_id, $_POST['filepath']);
        $str_output = '<span class="style1">File successfully deleted. If you are done uploading files, ' .
                '<a href="#" onclick="self.close();">click here</a> to close this window.</span>';
        setcookie("upload_out_txt", $str_output, time() + 300);
        setcookie("upload_out_b", "1", time() + 300);
    } else if ($action == 'add')
    {
        if (count_uploads($customer_id, $upload_id) >= 2)
        {
            $str_output = '<span class="style1">Problem: You have reached the maximum allowed uploads for this particular order. Please delete a file before continuing.</span>';
            setcookie("upload_out_txt", $str_output, time() + 300);
            setcookie("upload_out_b", "1", time() + 300);
        } else if (file_exists($target_path))
        {
            $str_output = '<span class="style1">Problem: A version of the file you are trying to upload already exists. Please delete the file from out servers before uploading again.</span>';
            setcookie("upload_out_txt", $str_output, time() + 300);
            setcookie("upload_out_b", "1", time() + 300);
        } else if (move_uploaded_file($FILES['uploadedfile']['tmp_name'], $target_path)) 
        {
            insert_to_database('uploaded_files', array($customer_id, $upload_id, 'now()', $target_path));
            $str_output = '<span class="style1">Success. The file was successfully uploaded. If you are done, <a href="" onclick="window.close();">click here to close the window</a></span>';
            setcookie("upload_out_txt", $str_output, time() + 300);
            setcookie("upload_out_b", "1", time() + 300);
        } else
        {
            $str_output = '<span class="style1">There was an error uploading the file, please try again!</span>';
            setcookie("upload_out_txt", $str_output, time() + 300);
            setcookie("upload_out_b", "1", time() + 300);
        }
    }



    return $str_output;
}

在嘗試實施修復后,這是我的php.ini文件:

extension_dir="/kunden/homepages/30/d93769495/htdocs/extensions";
extension=uploadprogress.so;
upload_max_filesize=150M;
post_max_size=210M;
max_input_time=1800;
file_uploads=1;
memory_limit=240M;
max_execution_time=1800;

檢查php.ini的以下設置:

  1. upload_max_filesize需要大於10 MiB( 10M )。

  2. post_max_size必須至少比upload_max_filesize大40%。

之所以需要這樣做,是因為某些舊的用戶代理將使用base64編碼進行上傳,這會給數據增加37%的開銷。 添加mime標頭和其他post參數,有很多理由使其高於upload_max_filesize

  1. max_input_time必須至少為900(15分鍾)。

您希望給用戶足夠的時間來上傳其文件。

這可能無法解決問題,但是在一個線程上我正在讀取它說IE6需要在輸入文件名之前處理MAX_FILE_SIZE行。 因此,請嘗試將以下行移動到表單頂部:

<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />

我不知道它是否有效,並且IE6要求按該順序進行解析,但這就是我正在閱讀的線程所說的解決方案。

還要檢查您的php.ini最大文件大小和超時。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM