我有一個表單上傳2個文件。他們可以上傳一個,或者同時上傳兩個。 當我上傳兩個小圖像文件(都在100kb以下)時,它們工作得很完美。但是如果一個文件比較大,比如大約200kb,那麼這個文件不起作用。我已經在下面的隱藏標記中將最大值設置爲「100000」,所以我不確定我還能做些什麼來解決這個問題?PHP上傳表單 - 無法上傳200kb圖像文件
<form enctype="multipart/form-data" action="upload.php" method="post">
<b>Image File</b><br />
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<b>Large Image</b>: <input type="file" name="uploadedfile1" size="30" /><br />
<b>Thumb Image</b>: <input type="file" name="uploadedfile2" size="30" /><br />
<center><input type="submit" name="submit" value="submit" class="button"></center>
</form>
當它的處理,它關係到這個PHP代碼:
$uploadedfileBase1 = basename($_FILES['uploadedfile1']['name']);
$uploadedfileTemp1 = $_FILES['uploadedfile1']['tmp_name'];
$uploadedfileBase2 = basename($_FILES['uploadedfile2']['name']);
$uploadedfileTemp2 = $_FILES['uploadedfile2']['tmp_name'];
// Large Image
$target_path_large = $target_path . "large/" . $uploadedfileBase1;
if(move_uploaded_file($uploadedfileTemp1, $target_path_large)) {
echo "<p>The <b>large</b> file \"$uploadedfileBase1\" has been uploaded.</p>";
} else{
echo "<p>There was an error uploading the <b>large</b> file <i>$uploadedfileBase1</i>, please try again!</p>";
}
// Thumb Image
$target_path_thumb = $target_path . "thumbs/" . $uploadedfileBase2;
if(move_uploaded_file($uploadedfileTemp2, $target_path_thumb)) {
echo "<p>The <b>thumbnail</b> file \"$uploadedfileBase2\" has been uploaded.</p>";
} else{
echo "<p>There was an error uploading the <b>thumbnail</b> file <i>$uploadedfileBase2</i>, please try again!</p>";
}
感謝您的閱讀!
我剛剛檢查了我的php.ini,並發現以下值(我認爲這些值都很慷慨,因此可能不是原因..?):post_max_size(8M),upload_max_filesize(2M),max_execution_time(30 ),max_input_time(60),memory_limit(24M) – Jay 2011-02-15 04:02:05