2

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?

Burak
  • 5,252
  • 3
  • 22
  • 30
Phil
  • 943
  • 2
  • 6
  • 18

1 Answers1

1

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

php_value post_max_size
php_value max_input_vars
Scott Anderson
  • 1,363
  • 1
  • 10
  • 19
  • max_input_vars is set to 1000 - so there should be no problem post_max_size is set to 8M - I think there is the problem (20 images à 500kb and text is bigger than 8M) do I have the possibility to increase those 8M? – Phil Jun 30 '15 at 12:24
  • Yep try setting it to 20M and see how it goes – Scott Anderson Jun 30 '15 at 12:24
  • For more info on post_max_size http://stackoverflow.com/questions/18441083/too-big-post-data-reduce-the-data-or-increase-the-post-max-size – Scott Anderson Jun 30 '15 at 12:39
  • Thank you, that was my problem! – Phil Jun 30 '15 at 13:10