douhoujun9304 2015-06-30 12:02
浏览 50
已采纳

HTML图像上传导致其他表单数据丢失

I have a simple upload form to upload multiple images

<form enctype="multipart/form-data" method="post" action="news/insert_news.php" class="form_news" id="newsform">
    <input type="text" class="inputHeading" name="heading" id="heading" maxlength="1000" placeholder="Überschrift" /><br /><br />
    <textarea rows="15" name="text" id="text" maxlength="10000" placeholder="Newstext"></textarea>
    <br /><br />
    <input placeholder="Datum (KLICK)" name="date" id="datepicker" /><br /><br />
    <input type="text" name="author" id="author" placeholder="Autor" /><br /><br />
    <input id="img" name="img[]" type="file" accept="image/*" multiple="multiple" /><br /><br />
    <button type="submit" id="sub">Absenden</button>
</form>

In my action file I check if the required fields are empty

if($title == "" || $text == "" || $author == "" || $date == "") {
    $_SESSION["formError"] = "<p class='formError'>Please fill in all fields.</p>";
    Header("Location: ../news_add.php");
    exit();
}

The values are catched via post

$title = mysql_real_escape_string(strip_tags($_POST["heading"]));
$text = nl2br(mysql_real_escape_string(strip_tags($_POST["text"], "<a><ul><li>")));
$text = trim($text);
$text = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $text);
$author = mysql_real_escape_string(strip_tags($_POST["author"]));
$date = mysql_real_escape_string(strip_tags($_POST["date"]));

When I upload a small number of images (like 5) it works very well. But when I try to upload a larger number of images (like 20) the data like title, text etc. gets lost and the error to fill in all fields is printed.

How can I prevent this behaviour or is there any way to do so?

  • 写回答

1条回答 默认 最新

  • doupinyan0186 2015-06-30 12:16
    关注

    Your POST may be hitting limits. You could check the following settings in .htaccess

    php_value post_max_size
    php_value max_input_vars
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题