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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.