next Posted April 22, 2008 Share Posted April 22, 2008 upload.php <?php if(isset($_POST['submitted'])) { if (!isset($_POST['upload'])) { include "upload.php"; exit(); } if ($_FILES['pix']['tmp_name'] == "none") { echo "<p style = 'font-weight: bold;'>File didn't successfully upload. Check he file size. File must be less than 500K.</p>"; include "upload.php"; exit(); } if (!preg_match("/image/", $_FILES['pix']['type'])) { echo $_FILES['pix']['type']; echo "<p style = 'font-weight: bold';>The file has to be an image."; include "upload.php"; exit(); } $destination = 'C:\data' . "\\" . $_FILES['pix']['name']; $temp_file = $_FILES['pix']['tmp_name']; move_uploaded_file($temp_file, $destination); echo "<p style = 'font-weight: bold';>The file has been successfully uploaded: {$_FILES['pix']['name']} - {$_FILES['pix']['size']}</p>"; } ?> form.php: <html> <head> <title>form</title> </head> <body> <ol> <li>Enter the file name</li> <li>Click Upload Picture</li> </ol> <div style = 'text-align: center'><hr /> <form enctype = "multipart/form-data" action = "upload.php" method = "post"> <P><input type = "hidden" name = "MAX_FILE_SIZE" value = "512000" /> <input type = "file" name = "pix" size = "60" /></p> <input type = "hidden" name = "submitted" value = "1" /> <input type = "submit" name = "upload" value = "Upload Picture"> </form> </div> </body> </html> So if i run form.php, select any file but image, my processing page will start looping upload.php and constantly display echo "<p style = 'font-weight: bold';>The file has to be an image."; . How do i fix this? Link to comment https://forums.phpfreaks.com/topic/102404-exit-not-working/ Share on other sites More sharing options...
Northern Flame Posted April 22, 2008 Share Posted April 22, 2008 this has nothing to do with exit() if the current file running is upload,php, why do you include it again? i see the file included a lot include "upload.php"; thats causing the loop, remove all the includes that include upload.php and it will stop looping Link to comment https://forums.phpfreaks.com/topic/102404-exit-not-working/#findComment-524419 Share on other sites More sharing options...
next Posted April 22, 2008 Author Share Posted April 22, 2008 damn, i needed to include form.php . Thanks. Link to comment https://forums.phpfreaks.com/topic/102404-exit-not-working/#findComment-524428 Share on other sites More sharing options...
Northern Flame Posted April 22, 2008 Share Posted April 22, 2008 you're welcome Link to comment https://forums.phpfreaks.com/topic/102404-exit-not-working/#findComment-524431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.