Solarpitch Posted October 31, 2007 Share Posted October 31, 2007 Hi Guys, I am currently using the below Ian Selby script to generate an thumbnail from an image and save it to the server. There is noting wrong with the script as I have tested it on different servers and use it on other sites, and it works fine. However, on a new site I am developing the thumbnail it tries to copy is just a black image. Then gives me the message... "Warning: imagecopyresampled(): 7 is not a valid Image resource" My php has gd enabled also. I am not gonna post the thumbnail.inc.php file with the associated functions as I know this code already works. Like I said I think its an issue with something else. Can anyone suggest anything thats work trying? I've been 3 days at this so I have to seek some help now. Thanks. $imagedir = "property_images/"; $timest = time(); $image1 = $_FILES['image1']['tmp_name']; if($image1 != ""){ $image1exists = 1; $includesimage = '1'; } if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); } if($image1exists == 1){ $image1 = $imagedir.$timest."AA".basename($_FILES['image1']['name']); } if($image1exists == 1){ $image1a = $imagedir."THUMB".$timest."AA".basename($_FILES['image1']['name']); } if($_FILES['image1']['tmp_name'] != ""){ echo "hello"; list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); if($width > $height){ $istaller = "0";} if($width < $height){ $istaller = "1";} if($width == $height){ $istaller = "2";} $thumb = new Thumbnail($image1file); if($istaller == "0"){ $thumb->resize('0','160'); $thumb->cropFromCenter('160'); }elseif($istaller == "1"){ $thumb->resize('160','0'); $thumb->cropFromCenter('160'); }else{ $thumb->resize('160','160'); } $thumb->save($image1a,100); if($height > "650"){ $thumb2 = new Thumbnail($image1file); if($istaller == "0"){ $thumb2->resize('0','650'); $thumb2->cropFromCenter('650'); }elseif($istaller == "1"){ $thumb2->resize('650','0'); $thumb2->cropFromCenter('650'); }else{ $thumb2->resize('650','650'); } $thumb2->save($image1,100); } } Just the imagecopyresampled() in thumbnail.inc.php imagecopyresampled( $this->workingImage, $this->oldImage, 0, 0, $startX, $startY, $width, $height, $width, $height ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $width; $this->currentDimensions['height'] = $height; } Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/ Share on other sites More sharing options...
Solarpitch Posted October 31, 2007 Author Share Posted October 31, 2007 Hey again, can anyone help out on this? Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-382403 Share on other sites More sharing options...
MadTechie Posted November 1, 2007 Share Posted November 1, 2007 well the script posted is incompleate but as you say it work.. i would guess the file isn't uploading.. check file permissions etc check this part works.. move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-382452 Share on other sites More sharing options...
Solarpitch Posted November 1, 2007 Author Share Posted November 1, 2007 All permissions have been checked. The part quoted does work as it uploads the main image. The thumbnail seems to upload also, but it uploads as a black image. The way the script works is it sets a black background and then copies the image over it, but it doesnt seem to be doing the copying part and fails at the function I listed for whatever reason. The same code works on other sites I done so I cant understand why I am having problems with this script. Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-382639 Share on other sites More sharing options...
MadTechie Posted November 1, 2007 Share Posted November 1, 2007 the problem is related to $image1file, thus i assume its not copying.. without more debugging info its almost impossible to point to the problem Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-382642 Share on other sites More sharing options...
Solarpitch Posted November 1, 2007 Author Share Posted November 1, 2007 I've been at this for days now and its really holding back my project ... When I get home later I will try and post as much debugging information/ warning's as I can, see if I can pin point the issue a little more. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-382647 Share on other sites More sharing options...
Solarpitch Posted November 2, 2007 Author Share Posted November 2, 2007 Hi, I did'nt get a chance to gather any error's yesterday buy just in relation to what you about "problem is related to $image1file" I use the exact same code and file permissions on 2 other sites and the thumbnail seems to upload fine. Could this problem even be related to the GD Library on this sites server... although I dont think so. What kind of debugging code could I try? I am not quite sure what the below message is saying but it must be the problem that is stopping the image copying to the thumbnail "Warning: imagecopyresampled(): 7 is not a valid Image resource" Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-383414 Share on other sites More sharing options...
MadTechie Posted November 2, 2007 Share Posted November 2, 2007 try this.. see what gets returned <?php $check = move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); var_dump($check, $image1file); die("END");// if($width > $height){ $istaller = "0";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-383490 Share on other sites More sharing options...
Solarpitch Posted November 2, 2007 Author Share Posted November 2, 2007 cool... again, I'll have to try it after work. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-383497 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Hi, I inserted that code into the script and gave me this result... bool(false) NULL END if($_FILES['image1']['tmp_name'] != ""){ list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); $check = move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); var_dump($check, $image1file); die("END");// if($width > $height){ $istaller = "0";} Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-383952 Share on other sites More sharing options...
MadTechie Posted November 3, 2007 Share Posted November 3, 2007 Problem with the upload this line fails.. move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); reason..is this $image1file is not being set add line (see comments) <?php $image1 = $_FILES['image1']['tmp_name']; //ADD echo "Testing123:"; var_dump($_FILES); if($image1 != ""){ $image1exists = 1; $includesimage = '1'; } if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384001 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Hi, I got a chance to insert that code there but I dont seem to be able to see the output from it as when the form is submitted with an image, it just reloads that page (as a blank page) and prints the address/ URL of the page along the top This only happens when I include an image in the upload. I am thinking it could be to do with the way the header is set, but maybe not. I'll print the code again below to show you the lot... <?php session_start(); include('../params/params.php'); include_once('thumbnail.inc.php'); if(!isset($_SESSION['valid_admin'])) { header("Location:index.php"); } $process = ""; $process = isset($_POST['process']) ? $_POST['process'] : ''; if ($process != "execute") { //not being submitted... } else { $county=""; $location=""; $type=""; $price="";$bedrooms="";$sale_type="";$description="";$accomodation=""; $county = $_POST['county']; $location = $_POST['location']; $type = $_POST['type']; $address = $_POST['address']; $price = $_POST['price']; $bedrooms = $_POST['bedrooms']; $sale_type = $_POST['sale_type']; $description = $_POST['description']; $features = $_POST['features']; $accomodation = $_POST['accomodation']; if($county == ""){ $countyerror = "Please select a county."; $error=1; }elseif($location == ""){ $locationerror = "Please select a location."; $error=1; }elseif($type == ""){ $typeerror = "Please select a property type."; $error=1; }elseif($address == ""){ $addresserror = "Please enter an address for this property."; $error=1; }elseif($price == ""){ $priceerror = "Please enter a price for this property."; $error=1; }elseif($description == ""){ $descriptionerror = "Please enter a description for this property."; $error=1; } if($error == 1){ //an error occured cant save... }else{ $imagedir = "property_images/"; $timest = time(); $image1 = $_FILES['image1']['tmp_name']; echo "Testing123:"; var_dump($_FILES); if($image1 != ""){ $image1exists = 1; $includesimage = '1'; } $image1exists=""; $image1a=""; if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } if($image1exists) { $image1 = $imagedir.$timest."AA".basename($_FILES['image1']['name']); } if($image1exists) { $image1a = $imagedir."THUMB".$timest."AA".basename($_FILES['image1']['name']); } if($_FILES['image1']['tmp_name'] != ""){ list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); if($width > $height){ $istaller = "0";} if($width < $height){ $istaller = "1";} if($width == $height){ $istaller = "2";} $thumb = new Thumbnail($image1file); if($istaller == "0"){ $thumb->resize('0','100'); $thumb->cropFromCenter('100'); }elseif($istaller == "1"){ $thumb->resize('100','0'); $thumb->cropFromCenter('100'); }else{ $thumb->resize('100','100'); } $thumb->save($image1a,100); if($height > "650"){ $thumb2 = new Thumbnail($image1file); if($istaller == "0"){ $thumb2->resize('0','650'); $thumb2->cropFromCenter('650'); }elseif($istaller == "1"){ $thumb2->resize('650','0'); $thumb2->cropFromCenter('650'); }else{ $thumb2->resize('650','650'); } $thumb2->save($image1,100); } } $insertproperty=""; insertproperty($county, $location, $type, $address, $price, $bedrooms, $sale_type, $description, $features, $accomodation, $image1, $image1a, $image2, $image3, $image4, $image5, $image6); if($insertproperty == 0){ echo $generalerror = "Error uplaoding files(s)."; }else{ echo $generalerror = "Files Uploaded."; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384215 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Hi, I got a chance to run that script. I just printed out the full php script on the page below so you can see the lot. When I inserted you code in the script I got... Testing123: array(6) { ["image1"]=> array(5) { ["name"]=> string(9) "house.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpJV1JUm" ["error"]=> int(0) ["size"]=> int(82082) } ["image2"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image3"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image4"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image5"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image6"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } } I am set:string(37) "property_images/1194103595AAhouse.jpg" Full php page code... <?php session_start(); include('../params/params.php'); include_once('thumbnail.inc.php'); if(!isset($_SESSION['valid_admin'])) { header("Location:index.php"); } $process = ""; $process = isset($_POST['process']) ? $_POST['process'] : ''; if ($process != "execute") { //not being submitted... } else { $county=""; $location=""; $type=""; $price="";$bedrooms="";$sale_type="";$description="";$accomodation=""; $county = $_POST['county']; $location = $_POST['location']; $type = $_POST['type']; $address = $_POST['address']; $price = $_POST['price']; $bedrooms = $_POST['bedrooms']; $sale_type = $_POST['sale_type']; $description = $_POST['description']; $features = $_POST['features']; $accomodation = $_POST['accomodation']; if($county == ""){ $countyerror = "Please select a county."; $error=1; }elseif($location == ""){ $locationerror = "Please select a location."; $error=1; }elseif($type == ""){ $typeerror = "Please select a property type."; $error=1; }elseif($address == ""){ $addresserror = "Please enter an address for this property."; $error=1; }elseif($price == ""){ $priceerror = "Please enter a price for this property."; $error=1; }elseif($description == ""){ $descriptionerror = "Please enter a description for this property."; $error=1; } if($error == 1){ //an error occured cant save... }else{ $imagedir = "property_images/"; $timest = time(); $image1 = $_FILES['image1']['tmp_name']; echo "Testing123:"; var_dump($_FILES); if($image1 != ""){ $image1exists = 1; $includesimage = '1'; } $image1exists=""; $image1a=""; if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } if($image1exists) { $image1 = $imagedir.$timest."AA".basename($_FILES['image1']['name']); } if($image1exists) { $image1a = $imagedir."THUMB".$timest."AA".basename($_FILES['image1']['name']); } if($_FILES['image1']['tmp_name'] != ""){ list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); if($width > $height){ $istaller = "0";} if($width < $height){ $istaller = "1";} if($width == $height){ $istaller = "2";} $thumb = new Thumbnail($image1file); if($istaller == "0"){ $thumb->resize('0','100'); $thumb->cropFromCenter('100'); }elseif($istaller == "1"){ $thumb->resize('100','0'); $thumb->cropFromCenter('100'); }else{ $thumb->resize('100','100'); } $thumb->save($image1a,100); if($height > "650"){ $thumb2 = new Thumbnail($image1file); if($istaller == "0"){ $thumb2->resize('0','650'); $thumb2->cropFromCenter('650'); }elseif($istaller == "1"){ $thumb2->resize('650','0'); $thumb2->cropFromCenter('650'); }else{ $thumb2->resize('650','650'); } $thumb2->save($image1,100); } } $insertproperty=""; insertproperty($county, $location, $type, $address, $price, $bedrooms, $sale_type, $description, $features, $accomodation, $image1, $image1a, $image2, $image3, $image4, $image5, $image6); if($insertproperty == 0){ echo $generalerror = "Error uplaoding files(s)."; }else{ echo $generalerror = "Files Uploaded."; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384219 Share on other sites More sharing options...
MadTechie Posted November 3, 2007 Share Posted November 3, 2007 try this change if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } to if($image1exists == 1){ $image1file = dirname(__FILE__)."/".$imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384286 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Ok, I ran that and got the below result. I thumbnail still uploaded as a black 100x100 image, but the main image uploaded fine as usual. Testing123:array(6) { ["image1"]=> array(5) { ["name"]=> string(9) "house.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpaclUz9" ["error"]=> int(0) ["size"]=> int(82082) } ["image2"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image3"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image4"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image5"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image6"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } } I am set:string(71) "/home/mysite/www/dub/admin/property_images/1194110836AAhouse.jpg" Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384315 Share on other sites More sharing options...
MadTechie Posted November 3, 2007 Share Posted November 3, 2007 oops i should of said add this line back in $check = move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); var_dump($check, $image1file); //<==This line Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384416 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Umm... I am not quite sure whats happining now .. The page just seems to reload blank with noting on it accept it prints the URL/ address of the page at the top. Below is the exact script I ran. <?php session_start(); error_reporting(0); include('../params/params.php'); include_once('thumbnail.inc.php'); if(!isset($_SESSION['valid_admin'])) { header("Location:index.php"); } $error = ""; $image2 = ""; $process = ""; $process = isset($_POST['process']) ? $_POST['process'] : ''; $countyerror=""; $locationerror=""; $typeerror=""; $addresserror=""; $priceerror=""; $descriptionerror="";$bedroomerror=""; if ($process != "execute") { //not being submitted... } else { $county=""; $location=""; $type=""; $price="";$bedrooms="";$sale_type="";$description="";$accomodation=""; $county = $_POST['county']; $location = $_POST['location']; $type = $_POST['type']; $address = $_POST['address']; $price = $_POST['price']; $bedrooms = $_POST['bedrooms']; $sale_type = $_POST['sale_type']; $description = $_POST['description']; $features = $_POST['features']; $prop = $_POST['prop']; $accomodation = $_POST['accomodation']; if($county == ""){ $countyerror = "Please select a county."; $error=1; }elseif($location == ""){ $locationerror = "Please select a location."; $error=1; }elseif($type == ""){ $typeerror = "Please select a property type."; $error=1; }elseif($address == ""){ $addresserror = "Please enter an address for this property."; $error=1; }elseif($price == ""){ $priceerror = "Please enter a price for this property."; $error=1; }elseif($description == ""){ $descriptionerror = "Please enter a description for this property."; $error=1; } if($error == 1){ //an error occured cant save... }else{ $imagedir = "property_images/"; $timest = time(); $image1 = $_FILES['image1']['tmp_name']; echo "Testing123:"; var_dump($_FILES); if($image1 != ""){ $image1exists = 1; $includesimage = '1'; } $image1exists=""; $image1a=""; if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } if($image1exists) { $image1 = $imagedir.$timest."AA".basename($_FILES['image1']['name']); } if($image1exists) { $image1a = $imagedir."THUMB".$timest."AA".basename($_FILES['image1']['name']); } if($_FILES['image1']['tmp_name'] != ""){ list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); $check = move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); var_dump($check, $image1file); if($width > $height){ $istaller = "0";} if($width < $height){ $istaller = "1";} if($width == $height){ $istaller = "2";} $thumb = new Thumbnail($image1file); if($istaller == "0"){ $thumb->resize('0','100'); $thumb->cropFromCenter('100'); }elseif($istaller == "1"){ $thumb->resize('100','0'); $thumb->cropFromCenter('100'); }else{ $thumb->resize('100','100'); } $thumb->save($image1a,100); if($height > "650"){ $thumb2 = new Thumbnail($image1file); if($istaller == "0"){ $thumb2->resize('0','650'); $thumb2->cropFromCenter('650'); }elseif($istaller == "1"){ $thumb2->resize('650','0'); $thumb2->cropFromCenter('650'); }else{ $thumb2->resize('650','650'); } $thumb2->save($image1,100); } } $insertproperty=""; insertproperty($county, $location, $type, $address, $price, $bedrooms, $sale_type, $description, $features, $accomodation, $image1, $image1a, $image2, $image3, $image4, $image5, $image6, $prop); if($insertproperty == 0){ echo $generalerror = "Error uplaoding files(s)."; }else{ echo $generalerror = "Files Uploaded."; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384428 Share on other sites More sharing options...
Solarpitch Posted November 3, 2007 Author Share Posted November 3, 2007 Scratch that last post! I Put the below variables in the wrong place.. $image1exists=""; $image1a=""; Ok when I added that line you said I got... Testing123:array(6) { ["image1"]=> array(5) { ["name"]=> string(9) "house.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpud7aBT" ["error"]=> int(0) ["size"]=> int(82082) } ["image2"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image3"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image4"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image5"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image6"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } } I am set:string(37) "property_images/1194126236AAhouse.jpg" bool(true) string(37) "property_images/1194126236AAhouse.jpg" Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384432 Share on other sites More sharing options...
MadTechie Posted November 4, 2007 Share Posted November 4, 2007 Erm.. did you do this ? try this change if($image1exists == 1){ $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } to if($image1exists == 1){ $image1file = dirname(__FILE__)."/".$imagedir.$timest."AA".basename($_FILES['image1']['name']); //ADD THIS echo "I am set:"; var_dump($image1file); } Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384540 Share on other sites More sharing options...
Solarpitch Posted November 4, 2007 Author Share Posted November 4, 2007 Tried it with that there and I got... Thumbnail still uploaded as a black image. This is the strangest thing I've ever come across in my life! Testing123:array(6) { ["image1"]=> array(5) { ["name"]=> string(9) "house.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpb7VdRV" ["error"]=> int(0) ["size"]=> int(82082) } ["image2"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image3"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image4"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image5"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } ["image6"]=> array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } } I am set:string(71) "/home/mysite/www/dub/admin/property_images/1194138220AAhouse.jpg" bool(true) string(71) "/home/mysite/www/dub/admin/property_images/1194138220AAhouse.jpg" Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384545 Share on other sites More sharing options...
MadTechie Posted November 4, 2007 Share Posted November 4, 2007 i gave the code a quick clean up.. try it now <?php session_start(); include('../params/params.php'); include_once('thumbnail.inc.php'); if(!isset($_SESSION['valid_admin'])) { header("Location:index.php"); } $process = ""; $process = isset($_POST['process']) ? $_POST['process'] : ''; if ($process != "execute") { //not being submitted... }else{ $county=""; $location=""; $type=""; $price="";$bedrooms="";$sale_type="";$description="";$accomodation=""; $county = $_POST['county']; $location = $_POST['location']; $type = $_POST['type']; $address = $_POST['address']; $price = $_POST['price']; $bedrooms = $_POST['bedrooms']; $sale_type = $_POST['sale_type']; $description = $_POST['description']; $features = $_POST['features']; $accomodation = $_POST['accomodation']; if($county == "") { $countyerror = "Please select a county."; $error=1; }elseif($location == ""){ $locationerror = "Please select a location."; $error=1; }elseif($type == ""){ $typeerror = "Please select a property type."; $error=1; }elseif($address == ""){ $addresserror = "Please enter an address for this property."; $error=1; }elseif($price == ""){ $priceerror = "Please enter a price for this property."; $error=1; }elseif($description == ""){ $descriptionerror = "Please enter a description for this property."; $error=1; } if($error == 1) { //an error occured cant save... }else{ $imagedir = dirname(__FILE__)."/property_images/"; $timest = time(); $image1 = $_FILES['image1']['tmp_name']; if($image1 != "") { $image1exists = 1; $includesimage = '1'; } $image1exists=""; $image1a=""; if($image1exists == 1) { $image1file = $imagedir.$timest."AA".basename($_FILES['image1']['name']); $image1 = $imagedir.$timest."AA".basename($_FILES['image1']['name']); $image1a = $imagedir."THUMB".$timest."AA".basename($_FILES['image1']['name']); if($_FILES['image1']['tmp_name'] != "") { list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); $C = move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); if(!$C) die("Upload Failed #1"); if($width > $height){ $istaller = "0";} if($width < $height){ $istaller = "1";} if($width == $height){ $istaller = "2";} $thumb = new Thumbnail($image1file); if($istaller == "0") { $thumb->resize('0','100'); $thumb->cropFromCenter('100'); }elseif($istaller == "1"){ $thumb->resize('100','0'); $thumb->cropFromCenter('100'); }else{ $thumb->resize('100','100'); } $thumb->save($image1a,100); if($height > "650") { $thumb2 = new Thumbnail($image1file); if($istaller == "0") { $thumb2->resize('0','650'); $thumb2->cropFromCenter('650'); }elseif($istaller == "1"){ $thumb2->resize('650','0'); $thumb2->cropFromCenter('650'); }else{ $thumb2->resize('650','650'); } $thumb2->save($image1,100); } } $insertproperty=""; insertproperty($county, $location, $type, $address, $price, $bedrooms, $sale_type, $description, $features, $accomodation, $image1, $image1a, $image2, $image3, $image4, $image5, $image6); if($insertproperty == 0) { echo $generalerror = "Error uplaoding files(s)."; }else{ echo $generalerror = "Files Uploaded."; } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384568 Share on other sites More sharing options...
Solarpitch Posted November 4, 2007 Author Share Posted November 4, 2007 Thanks for your help with this! Noting seems to happen when I run that code. It just reloads the page and doesnt update the database or add any files to the server. I'll have a look to see if I can see a problem. Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384571 Share on other sites More sharing options...
Solarpitch Posted November 4, 2007 Author Share Posted November 4, 2007 I got your code to run there. You had $image1exists=""; after it was set.. $timest = time(); $image1 = $_FILES['image1']['tmp_name']; $image1exists=""; $image1a=""; if($image1 != "") { $image1exists = 1; $includesimage = '1'; } The thumbnail still uploaded as a black image again. If we cant get this to work, is there any workaround or other thumbnail code you could advise in putting in its place. Its just strange that the code works on my other sites! Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-384576 Share on other sites More sharing options...
MadTechie Posted November 5, 2007 Share Posted November 5, 2007 if its still failing your need to post the class.. Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-385250 Share on other sites More sharing options...
MadTechie Posted November 5, 2007 Share Posted November 5, 2007 Heres a script i cleaned up read the full post (its shortish) http://www.phpfreaks.com/forums/index.php/topic,162782.0.html Quote Link to comment https://forums.phpfreaks.com/topic/75529-solved-issue-with-thumbnail-script-could-be-server-related/#findComment-385253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.