Meridius Posted August 12, 2012 Share Posted August 12, 2012 Hello, I am trying to pass variables to a page, should be an easy job you say? Same thoughts here but i can't really find the problem. For starters I have a simple form with a textfield and a upload field. (i'm a dutchy so labels/errors will be foreign to most) <form action="upload_exec.php" method="post" enctype="multipart/form-data"> <table border="0"> <tr> <td>Mapnaam:</td> <td><input type="text" name="folder" size="35" /></td> </tr> <tr> <td>Bestanden:</td> <td><input type="file" name="file[]" id="file" multiple=""/></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> Basically i can't see anything wrong with it, on the form action page i constantly get the error message saying the variable isn't filled. <?php include('ResizeImage.php'); if (!isset($_POST['folder'])) { echo "Er is geen map aangegeven"; } else { $dirname = $_POST["folder"]; $filename = ('./' . $dirname . '/'); if (!file_exists($filename)) { mkdir("{$dirname}"); } for($i = 0; $i < count($_FILES['file']['name']); $i++) { $allowedExts = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png"); $extension = end(explode(".", $_FILES["file"]["name"][$i])); if ((($_FILES["file"]["type"][$i] == "image/gif") || ($_FILES["file"]["type"][$i] == "image/GIF") || ($_FILES["file"]["type"][$i] == "image/jpeg") || ($_FILES["file"]["type"][$i] == "image/JPEG") || ($_FILES["file"]["type"][$i] == "image/pjpeg") || ($_FILES["file"]["type"][$i] == "image/PJPEG")) && ($_FILES["file"]["size"][$i] < 200000000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"][$i] > 0) { echo "Foutode: " . $_FILES["file"]["error"][$i] . "<br />"; } else { if (file_exists("" . $dirname . "/" . $_FILES["file"]["name"][$i])) { echo $_FILES["file"]["name"][$i] . " already exists. <br />"; } else { move_uploaded_file($_FILES["file"]["tmp_name"][$i], "" . $dirname . "/" . $_FILES["file"]["name"][$i]); echo "Opgeslagen in: " . "" . $dirname . "/" . $_FILES["file"]["name"][$i] . " <br />"; $image = new ResizeImage(); $image->load("" . $dirname . "/" . $_FILES["file"]["name"][$i]); $image->resizeToHeight(1080); $image->save("" . $dirname . "/" . $_FILES["file"]["name"][$i]); $image->resizeToHeight(38); $image->save("" . $dirname . "/thumb_" . $_FILES["file"]["name"][$i]); } } } else { echo "Geen geldig bestand <br />"; } } } ?> Any insights would be really helpfull or maby a work-around if this doesn't work. Is it an idea to use $_GET or sessions if nothing seems wrong? I have tested in Chrome, FireFox 14, IE 9 and all give the same result. Kind regards/Thanks in advance, Erik Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/ Share on other sites More sharing options...
scootstah Posted August 12, 2012 Share Posted August 12, 2012 You are probably exceeding the post_max_size setting in the php.ini, which would cause $_POST and $_FILES to be empty. Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/#findComment-1368821 Share on other sites More sharing options...
Christian F. Posted August 12, 2012 Share Posted August 12, 2012 What's the output of the following lines of code? echo '<pre>';var_dump ($_POST); var_dump ($_FILES);die (); Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/#findComment-1368822 Share on other sites More sharing options...
Pikachu2000 Posted August 12, 2012 Share Posted August 12, 2012 See what your $_POST and $_FILES arrays actually contain when the form is submitted and use that information to start debugging the problem. echo '$_POST array:<pre>'; print_r($_POST); echo '</pre><br>$_FILES array:<pre>'; print_r($_FILES); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/#findComment-1368823 Share on other sites More sharing options...
Meridius Posted August 12, 2012 Author Share Posted August 12, 2012 Thanks all for the very quick responses. I put both codes in the form action file and well, here are the results: ChristianF code: array empty array empty Pikachu2000 code: $_POST array: Array ( ) $_FILES array: Array ( ) I tried it again after closing all the browsers and then restarting WAMP fully before trying again. It seems to work fine for a single file but when selecting multiple it seems to fail. Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/#findComment-1368828 Share on other sites More sharing options...
Meridius Posted August 12, 2012 Author Share Posted August 12, 2012 Sorry scootstah, i missed your post. You seem to have very very good point there! I have tested some things and indeed when choosing smaller images it results in success so the uploads have indeed exceeded the maximum size it seems. I will have to sort that out later today since i have to go now but thanks so much for pointing me to it. Link to comment https://forums.phpfreaks.com/topic/266984-_post-not-working/#findComment-1368829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.