Thanks Terje!
Once again your suggestions have worked nicely!.
The only thing left to do is, id like to be able to know how to stop the script from going any further at the point that it discovers it is not a JPG.
<head>
<STYLE>UNKNOWN {
TEXT-DECORATION: none
}
A:hover {
CURSOR: crosshair; COLOR: white; TEXT-DECORATION: none; COLOR: white; BACKGROUND-COLOR: #0080FF;}
</STYLE>
<title>Thankyou!</title>
</head>
<body bgcolor="#00003E" link="#FFFFFF" vlink="#FFFFFF" leftmargin="0">
<?
include "../inc/top.php";
?>
<div align="center">
<table border="0" width="100%">
<tr>
<td width=20% valign="top" align="left">
<?
include "../inc/left.php";
?>
</td>
<td width="60%" align="center" valign="top">
<font color="#FFFFFF" face="Arial" size="2"><br>
<?
include "../inc/header.inc";
include "../inc/settings.inc";
// $imageattr = GetImageSize("filename.jpg");
// if ($imageattr[2] != 'image/jpeg') {
// print 'Not a valid JPEG image';
// } else {
// print 'Valid JPEG image';
// }
if ($image_name != "") {
copy("$image", "temp/original/$image_name") or die ("Couldn't copy the file.");
$imageattr = GetImageSize("temp/original/$image_name");
if ($imageattr[2] == 2) $validImage = 1; else $validImage = 0;
if (!$validImage) {
print 'This image is not a valid JPG image.<br>';
unlink("temp/original/$image_name");
} else {
exec("/usr/bin/convert -geometry 200 \"temp/original/$image_name\" \"temp/thumbs/$image_name\"", $error);
exec("/usr/bin/convert -quality 80 \"temp/original/$image_name\" \"temp/big/$image_name\"", $error);
}
} else {
die("You forgot to add a filename. Please click the back button and try again.");
}
$insert_data = "INSERT INTO temp (image_name, image, name, email, country, airfield, rego, remarks, airline, date, month, year) VALUES ('$image_name', 'processed/big/$image_name', '$name', '$email', '$country', '$airfield', '$rego', '$remarks', '$airline', '$date', '$month', '$year')";
mysql_query($insert_data) or die("Couldn't insert data.");
$msg = "Another Pic has been uploaded!!\n\n";
$msg .= "Photographer:\t$name\n";
$msg .= "Sender E-Mail:\t$email\n";
$msg .= "Airline:\t$airline\n";
$msg .="Country:\t$country\n";
$msg .= "Registration:\t$rego\n";
$msg .= "Remarks:\t$remarks\n";
$msg .= "Image is located at:\t$website/$img_location\n";
$msg .= "After processing it will be at:\t$website/$img_processed";
$recipient = "me@host.com";
$subject = "File $image_name Uploaded!!";
$mailheaders = "From:uploads<> \n";
$mailheaders .= "Reply-To: $email\n\n";
mail($recipient, $subject, $msg, $mailheaders);
print "<font face=\"Arial\" size=\"2\" color=\"white\">Thank you for uploading your photo to us. As soon as we have time we will get round to processing it for you<br><br>Click <a href=\"\">HERE</a>to add another photo</font>\n";
?>
</td>
<td width=20%>
</td>
</tr>
</table>
</div>
<?
include "../inc/footer.inc";
?>
</body>
I have some other stuff down in the script - for example an email gets sent to me with every upload, and also a thankyou message. I dont obviously wan tthem to print out if it is not a JPG - but at present it is completing the rest of the script even if it not a JPG (except for the imagemagik stuff.). THe sql info is all still being entered.
How do i get it to die at the:
print 'This image is not a valid JPG image.<br>';
Many thanks once again. !
Dave