dlebowski Posted September 6, 2007 Share Posted September 6, 2007 I have spent all day working on this and cannot figure this out. Here is the error that I get: "function.imagejpeg</a>]: Unable to open 'images//thumbs/SBCB9196A.jpg'". This would indicate that I am having a problem with getting a value for the $pathToThumbs variable. No matter what I assign the $Date variable, I cannot get it to find it. Can someone please let me know if my syntax is wrong? Thanks for your help. $Date=$_GET['Date']; //Create variable $pathToThumbs = "../images/".$Date."/thumbs/"; // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/ Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Well, evidently, there is no 'Date' variable being passed in the GET array. How is this supposed to being passed? Where is it comming from? Are you sure there is a capital D on date? You're sure you're not using the POST method to submit your form? We'll need somre more code. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343194 Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 i agree where is the date variable being defined? Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343195 Share on other sites More sharing options...
dlebowski Posted September 6, 2007 Author Share Posted September 6, 2007 It is coming over from a form and GET does work because the beginning portion of my code works fine using GET. The two pieces I have provided are just snippets of a larger script. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343197 Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Well obviously it doesn't work, otherwise there would be something in the $Date variable! If you were to echo $Date: $Date=$_GET['Date']; echo 'Date: '.$date.'<br />'; You would have a blank. Do you think we could see the form? Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343199 Share on other sites More sharing options...
squiggerz Posted September 6, 2007 Share Posted September 6, 2007 Tried dropping the concatenation? like $path = "../images/$Date/blah/blah"; Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343200 Share on other sites More sharing options...
sneamia Posted September 6, 2007 Share Posted September 6, 2007 Tried dropping the concatenation? like $path = "../images/$Date/blah/blah"; I doubt that will fix anything. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343203 Share on other sites More sharing options...
squiggerz Posted September 6, 2007 Share Posted September 6, 2007 It's worked for me in the past somehow, guess it was a quote/doublequote problem or something tho.... would really help to see the rest of the code really.. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343206 Share on other sites More sharing options...
dlebowski Posted September 6, 2007 Author Share Posted September 6, 2007 Nope. It didn't work. I tried that already. Thanks anyway though. Here is the whole script. Keep in mind, everything is working except the thumbnail portion. <?php $ImageAuctionDate=$_GET['ImageAuctionDate']; if(is_dir("images/".$ImageAuctionDate."")) { } else { mkdir("images/".$ImageAuctionDate."", 0777); } echo 'Upload result:<br>'; // At least one symbol should be sent to response!!! $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$ImageAuctionDate."/"; $target_encoding = "ISO-8859-1"; echo '<pre>'; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File is valid, and was successfully uploaded.\n"; } else { echo 'No files sent. Script is OK!'; echo 'Here is some more debugging info:'; print_r($_FILES); echo "</pre>"; } include("dbinfo.inc.php"); mysql_connect("localhost",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $ImageAuctionDate=$_GET['ImageAuctionDate']; $pathToImages = "../images/".$ImageAuctionDate."/"; $pathToThumbs = "../images/".$ImageAuctionDate."/thumbs/"; $thumbWidth = "75"; function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { echo "Creating thumbnail for {$fname} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } createThumbs("images/".$ImageAuctionDate."/","images/".$imageAuctionDate."/thumbs/",100); ?> Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343209 Share on other sites More sharing options...
squiggerz Posted September 6, 2007 Share Posted September 6, 2007 last line $ImageAuctionDate."/","images/".$imageAuctionDate."/thumbs/",100); shouldnt that second variable be capitalized? like the first one. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343211 Share on other sites More sharing options...
dlebowski Posted September 6, 2007 Author Share Posted September 6, 2007 Yep. I spent 5 hours looking through this thing and don't know how I overlooked that. Thanks as usual! Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343217 Share on other sites More sharing options...
sneamia Posted September 6, 2007 Share Posted September 6, 2007 last line $ImageAuctionDate."/","images/".$imageAuctionDate."/thumbs/",100); shouldnt that second variable be capitalized? like the first one. Pwnt. Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343220 Share on other sites More sharing options...
squiggerz Posted September 6, 2007 Share Posted September 6, 2007 Woot, I just popped my 'support cherry' Glad to finally give a little back to this forum lol Quote Link to comment https://forums.phpfreaks.com/topic/68263-solved-need-assistance-with-my-syntax/#findComment-343222 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.