【发布时间】:2011-06-27 07:55:02
【问题描述】:
我有一个表格可以上传 2 个文件。他们可以上传一个,或者同时上传两个。 当我上传 2 个小图像文件(均小于 100kb)时,它们运行良好。但是如果一个文件更大,比如 200kb 左右,它就不起作用了。我已经在下面的隐藏标签中将最大值设置为“100000”,所以我不确定我还能做些什么来解决这个问题?
<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)
标签: php file forms upload size