nickyfraggle
12-09-2008, 05:10 PM
Hello,
This is my php code:
case "image":
//get all posted values
$image=$_POST['picture']; $id=$_POST['id'];
$make=$_POST['make']; $model=$_POST['model'];
$uploadDir = '/home/sites/test.co.uk/public_html/images/';
if(isset($_POST['upload'])) {
$fileName = $_FILES['picture']['name'];
$tmpName = $_FILES['picture']['tmp_name'];
$filePath = $uploadDir.$fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
//echo "Error uploading file";
}
if(!get_magic_quotes_gpc()){
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$insert=mysql_query("UPDATE cars SET image='$image' WHERE id='$id'", $link) or die("Update Query Error ".mysql_error());
}
if($result === true) {
$picture = open_image($uploadDir.$fileName);
if ($picture === false) { }
else{
function open_image($file) {
# JPEG:
$im = @imagecreatefromjpeg($file);
if ($im !== false) { return $im; }
# GIF:
$im = @imagecreatefromgif($file);
if ($im !== false) { return $im; }
# PNG:
$im = @imagecreatefrompng($file);
if ($im !== false) { return $im; }
return false;
}
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// Set a new width, and calculate new height
$new_width = 100;
$new_height = $height * ($new_width/$width);
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_resized, '../../car_images/'.$fileName);
$url="success.php";
header ("Location: $url");
}
}
I'm getting this error :
Fatal error: Call to undefined function: open_image() in /home/sites/test.co.uk/public_html/functions.php on line 123
Any idea why this might be? I''m pulling my hair out and I don't understand it!!
Thanks,
Nicky
This is my php code:
case "image":
//get all posted values
$image=$_POST['picture']; $id=$_POST['id'];
$make=$_POST['make']; $model=$_POST['model'];
$uploadDir = '/home/sites/test.co.uk/public_html/images/';
if(isset($_POST['upload'])) {
$fileName = $_FILES['picture']['name'];
$tmpName = $_FILES['picture']['tmp_name'];
$filePath = $uploadDir.$fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
//echo "Error uploading file";
}
if(!get_magic_quotes_gpc()){
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$insert=mysql_query("UPDATE cars SET image='$image' WHERE id='$id'", $link) or die("Update Query Error ".mysql_error());
}
if($result === true) {
$picture = open_image($uploadDir.$fileName);
if ($picture === false) { }
else{
function open_image($file) {
# JPEG:
$im = @imagecreatefromjpeg($file);
if ($im !== false) { return $im; }
# GIF:
$im = @imagecreatefromgif($file);
if ($im !== false) { return $im; }
# PNG:
$im = @imagecreatefrompng($file);
if ($im !== false) { return $im; }
return false;
}
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// Set a new width, and calculate new height
$new_width = 100;
$new_height = $height * ($new_width/$width);
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_resized, '../../car_images/'.$fileName);
$url="success.php";
header ("Location: $url");
}
}
I'm getting this error :
Fatal error: Call to undefined function: open_image() in /home/sites/test.co.uk/public_html/functions.php on line 123
Any idea why this might be? I''m pulling my hair out and I don't understand it!!
Thanks,
Nicky