Jump to content

exit() not working


next

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.