首先,我知道有人问过类似的问题,但是我的似乎不是服务器限制的文件大小....
当使用下面表格的一个页面并尝试发送到另一个包含脚本的文件时,它适用于小文件(小于 2MB)。但是,一个稍大的文件(大约 3MB)似乎可以正确传递 $_POST 变量,但脚本由于某些未知原因而失败。最后,一个 9MB 的测试文件根本无法发送 $_POST 变量,并且print_r($_POST)
每个变量都显示为未定义。
这是表格:
<form enctype="multipart/form-data" id="formEditTAPPS" method="POST" action="scripts/editTAPPSprocess.php">
Page ID Number: <? echo $id; ?>
<input type="hidden" name="id" value="<? echo $id; ?>" />
<br />
Page Title: <input type="text" name="newPageTitle" value="<?php echo $row['title']; ?>" style="width:300px;" />
<br />
Number of Pages in PDF: <input type="text" name="newNumberOfPages" value="<?php echo $row['num_pages']; ?>" style="width:30px;" />
<br />
TAPPS Category:
<select name="newCategory">
<? while ($row2 = mysql_fetch_array($data2)) {
$catIDfromCat = $row2['cat_id'];
$catName = $row2['cat_name'];
?><option value="<? echo $catIDfromCat; ?>" <?php if ($catIDfromPages==$catIDfromCat){echo "selected=\"selected\"";} ?> ><? echo $catName; ?></option>
<? } ?>
</select>
<br />
Last Updated: <? echo $row['last_updated']; ?>
<br />
Display Order: <input type="text" name="newDisplayOrder" value="<?php echo $row['display_order']; ?>" />
<br />
Existing PDF: <a href="/files/tapps/<? echo $row['filename']; ?>" /><? echo $row['filename']; ?></a>
<br />
Upload a New PDF: <input name="newPDF" type="file" />
<br />
<input type="submit" name="Submit" value="Update this TAPPS Page" style="margin: 20px 0 0 50px;" />
这是处理脚本:
include_once('../../../common/db/conn.php'); // Connect to the database
// Assigns the variables passed from the form.
$id = $_POST['id'];
$title = $_POST['newPageTitle'];
$num_pages = $_POST['newNumberOfPages'];
$cat_id = $_POST['newCategory'];
$display_order = $_POST['newDisplayOrder'];
$newPDF = basename($_FILES['newPDF']['name']);
// Try to upload the file...
$target = "../../../files/tapps/";
$target = $target . $newPDF;
if(move_uploaded_file($_FILES['newPDF']['tmp_name'], $target)) {
// Saves the data into the correct database table.
$sql = "UPDATE tapps_pages SET title='$title', num_pages='$num_pages', cat_id='$cat_id', display_order='$display_order', filename='$newPDF' WHERE id='$id'";
// Verifies the database stores the form results and sends the user to the "Success" page.
$result = mysql_query($sql);
if($result) {
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=../editTAPPSpage.php?id=$id&success=1\">";
} else {
echo "<br /><br />Bummer, something broke. =(<br /><br />";
print_r($_POST);
}
} else {
// Problem uploading the file
echo "<br /><br />Looks like there was a problem uploading the TAPPS page... Better tell Kevin!<br /><br />He's going to want to know this info, so please copy and paste it into the email...<br />";
print_r($_POST);
echo "<br /><br />";
print_r($_SERVER);
echo "<br /><br />";
print_r($_SESSION);
}
听起来upload_max_filesize
对我来说是个问题,但我已经用 php.ini 文件解决了这个问题:
memory_limit = 128M
max_execution_time = 600
upload_max_filesize = 50M
post_max_size = 64M
并phpinfo()
表明在重新启动 Apache 后更改卡住了。
我是否缺少可能导致超时或将文件大小限制为 2MB 的设置?提前感谢您的帮助!