上传大文件时未存储$ _POST变量

时间:2013-02-15 16:25:06

标签: php forms file-upload

首先,我知道有类似的问题已被提出,但我的服务器文件大小似乎不是....

当使用下面表单的一个页面并尝试发送到包含该脚本的另一个文件时,它适用于小文件(小于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. &nbsp;&nbsp;&nbsp;&nbsp; =(<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的设置?在此先感谢您的帮助!

0 个答案:

没有答案