If any of you see the problem, I'd really appreciate the fix... I'm a beginner working on a photo upload site.
Parse error: parse error, unexpected '{' in process_pic.php on line 54
<?php
header("Cache-control: private, no-cache");
header("Expires: Mon, 26 Jun 1997 05:00:00 GMT");
header("Pragma: no-cache");
include("title.php");
include("con.php");
$title = $_POST['title'];
$tags = $_POST['tags'];
$ip = $_SERVER['REMOTE_ADDR'];
$title = trim($title);
$title = stripslashes($title);
$title = strip_tags($title);
$tags = trim($tags);
$tags = stripslashes($tags);
$tags = strip_tags($tags);
if(!eregi("^[a-zA-Z0-9\ \-]{1,70}$", $title))
{
$_SESSION['title'] = $title;
}
if(!eregi("^[a-zA-Z0-9\ ]{1,70}$", $tags))
{
$_SESSION['tags'] = $tags;
}
if(isset($_SESSION['title']) or isset($_SESSION['tags']))
{
header('location: contribute.php');
die();
}
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 4194304))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists(file_exists("../img/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. The file was uploaded to the TEMP folder, but was never saved.";
}
else
{
$uploadedfile = $_FILES['file']['tmp_name'];
##############
if ($_FILES["file"]["type"] == "image/png")
{
$src = imagecreatefrompng($uploadedfile);
}
elseif ($_FILES["file"]["type"] == "image/gif")
{
$src = imagecreatefromgif($uploadedfile);
}
else
{
$src = imagecreatefromjpeg($uploadedfile);
}
######
list($width,$height)=getimagesize($uploadedfile);
if($width > 800)
{
if($width > $height)
{
$newwidth=800;
$newheight=($height/$width)*800;
}
elseif($width < $height)
{
$newheight=800;
$newwidth=($width/$height)*800;
}
else
{
$newwidth=800;
$newheight=($height/$width)*800;
}
}
else
{
$newwidth = $width;
$newheight = $height;
}
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "img/". $_FILES['file']['name'];
if ($_FILES["file"]["type"] == "image/png")
{
imagepng($tmp,$filename,100);
}
elseif ($_FILES["file"]["type"] == "image/gif")
{
imagegif($tmp,$filename,100);
}
else
{
imagejpeg($tmp,$filename,100);
}
imagedestroy($src);
imagedestroy($tmp);
$filen = $_FILES['file']['name'];
mysql_query("INSERT INTO `images` (`image`,`title`,`tags`,`ip`) VALUES ('$filen','$title', '$tags', '$ip')");
echo "<br/> SUCCESS!";
}
}
}
else
{
echo "Invalid file";
}
mysql_close($con);
?>
Every time I resort to asking for help, I find the answer almost immediately.
if (file_exists(file_exists("../img/" . $FILES["file"]["name"]))
should be: if (file_exists(file_exists("../img/" . $FILES["file"]["name"])))
with three ))) on the end instead of two ))