9911782 Posted November 26, 2007 Share Posted November 26, 2007 Hi I've been trying to Uploading Images/create Thumbnails to insert into my DB. I get so many errors when running this code. Here is My code: ================== <?php //@Language=VBScript?> <?php include("../Connections/fetwebsite.php"); if($_REQUEST["enter"]=="yes" ){ include("../connections/fetwebsite.php"); $sql="select MAX(ImageID) as maximageid from galleryImages"; //execute sql statements $rsUsers = mysql_query($sql, $fetcolleges) or die(mysql_error()); $rows_rsUsers = mysql_fetch_assoc($rsUsers); $total_num_Users = mysql_num_rows($rsUsers); $maximageid = $rows_rsUsers['maximageid']; $GalleryID = $_REQUEST['GalleryID']; $ImageID=$_REQUEST["ImageID"]; $Caption = $_POST["caption"]; $GalleryID = $_POST['GalleryID']; $ImageStatus = $_POST['ImageStatus']; $ImageFull = $_FILES['ImageFull']['ImageFull']; $tmpNameFull = $_FILES['ImageFull']['tmp_name']; $ImageThumb = $_FILES['ImageThumb']['ImageThumb']; $tmpNameThumb = $_FILES['ImageThumb']['tmp_name']; $fileName = $_FILES['ImageThumb']['name']; $tmpName = $_FILES['ImageThumb']['tmp_name']; $tmpName2 = $_FILES['ImageThumb']['tmp_name']; $file_size = $_FILES['ImageThumb']['size']; $fileType = $_FILES['ImageThumb']['type']; $DateAdded=date("Y/m/d H:i:s"); // you can change this to any directory you want // as long as php can write to it $uploadDir = '../photogalleries/'; //$DefaultPasswords['program'] = crypt('program'); // the files will be saved in filePath /// $filePath = $uploadDir . $fileName; $maximageid = $maximageid + 1; $ImageThumb = "thumb"."_".$maximageid."."."jpg"; $ImageFull = "photo"."_".$maximageid."."."jpg"; $filePath = $uploadDir . $fileName; $filePath2 = $uploadDir . $ImageThumb; $filePath3 = $uploadDir . $ImageFull; ///RESIZE THUMBNAIL/// // Set a maximum height and width $width = 115; $height = 147; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filePath); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = @imagecreatefromjpeg($filePath); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output $thumbsize = imagejpeg($image_p, null, 100); $thumbsize; if (function_exists('imagecreatefromjpeg') || function_exists('imagecreatetruecolor') || function_exists('imagecopyresampled') || function_exists('getimagesize')) { echo 'OK, you already have GD library installed'; } else { echo 'Sorry, it seem that GD library is not installed/enabled'; } ///END RESIZE THUMBNAIL/// // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false //$result = move_uploaded_file($tmpName, $filePath); $result1 = move_uploaded_file($tmpNameThumb, $filePath3); $result2 = move_uploaded_file($tmpNameFull, $filePath2); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $uploadDir = '../photogalleries/$fileName'; $sql="INSERT INTO galleryImages(Caption,GalleryID, ImageStatus, name,size, type, path,DateAdded,ImageThumb,ImageFull) values ('$Caption','".$_REQUEST['GalleryID']."','$ImageStatus','$fileName', '$file_size', '$fileType', '$filePath','$DateAdded','$ImageThumb','$ImageFull')"; $execute = mysql_query($sql, $fetcolleges) or die(mysql_error()); if($execute){ mysql_close($fetcolleges); //header("Location: galleryImages_setup.php"); } } ?> ================== These are the errors I get: ======= Warning: getimagesize(../photogalleries/darkie_02.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 68 Warning: Division by zero in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 70 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 78 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 80 Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 83 ============ I have GD library installed, and check the php.ini all is well, but still getting this erros. I dont know what to do now. Ps help me! Quote Link to comment Share on other sites More sharing options...
Lumio Posted November 26, 2007 Share Posted November 26, 2007 Please use the boardsearch Quote Link to comment Share on other sites More sharing options...
9911782 Posted November 27, 2007 Author Share Posted November 27, 2007 Hi Lumio I did use those board serached, but im still getting the errors. I have used the code provided in this forum, but still getting the same errors. Can u perhaps, explain to me what does above errors means? Ps Lumio help me. thank you Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted November 27, 2007 Share Posted November 27, 2007 None of your errors have anything to do with the actual line they return. Either give us the right code, or put this code in code tags to format it properly. Quote Link to comment Share on other sites More sharing options...
9911782 Posted November 27, 2007 Author Share Posted November 27, 2007 Hi HaLo2FrEeEk I dont understand you now. Because the code I posted here is the very same post that is giving me the errors I posted.Here is the Code: Here is My code: ================== <?php //@Language=VBScript?> <?php include("../Connections/fetwebsite.php"); if($_REQUEST["enter"]=="yes" ){ include("../connections/fetwebsite.php"); $sql="select MAX(ImageID) as maximageid from galleryImages"; //execute sql statements $rsUsers = mysql_query($sql, $fetcolleges) or die(mysql_error()); $rows_rsUsers = mysql_fetch_assoc($rsUsers); $total_num_Users = mysql_num_rows($rsUsers); $maximageid = $rows_rsUsers['maximageid']; $GalleryID = $_REQUEST['GalleryID']; $ImageID=$_REQUEST["ImageID"]; $Caption = $_POST["caption"]; $GalleryID = $_POST['GalleryID']; $ImageStatus = $_POST['ImageStatus']; $ImageFull = $_FILES['ImageFull']['ImageFull']; $tmpNameFull = $_FILES['ImageFull']['tmp_name']; $ImageThumb = $_FILES['ImageThumb']['ImageThumb']; $tmpNameThumb = $_FILES['ImageThumb']['tmp_name']; $fileName = $_FILES['ImageThumb']['name']; $tmpName = $_FILES['ImageThumb']['tmp_name']; $tmpName2 = $_FILES['ImageThumb']['tmp_name']; $file_size = $_FILES['ImageThumb']['size']; $fileType = $_FILES['ImageThumb']['type']; $DateAdded=date("Y/m/d H:i:s"); // you can change this to any directory you want // as long as php can write to it $uploadDir = '../photogalleries/'; //$DefaultPasswords['program'] = crypt('program'); // the files will be saved in filePath /// $filePath = $uploadDir . $fileName; $maximageid = $maximageid + 1; $ImageThumb = "thumb"."_".$maximageid."."."jpg"; $ImageFull = "photo"."_".$maximageid."."."jpg"; $filePath = $uploadDir . $fileName; $filePath2 = $uploadDir . $ImageThumb; $filePath3 = $uploadDir . $ImageFull; ///RESIZE THUMBNAIL/// // Set a maximum height and width $width = 115; $height = 147; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filePath); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = @imagecreatefromjpeg($filePath); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output $thumbsize = imagejpeg($image_p, null, 100); $thumbsize; if (function_exists('imagecreatefromjpeg') || function_exists('imagecreatetruecolor') || function_exists('imagecopyresampled') || function_exists('getimagesize')) { echo 'OK, you already have GD library installed'; } else { echo 'Sorry, it seem that GD library is not installed/enabled'; } ///END RESIZE THUMBNAIL/// // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false //$result = move_uploaded_file($tmpName, $filePath); $result1 = move_uploaded_file($tmpNameThumb, $filePath3); $result2 = move_uploaded_file($tmpNameFull, $filePath2); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $uploadDir = '../photogalleries/$fileName'; $sql="INSERT INTO galleryImages(Caption,GalleryID, ImageStatus, name,size, type, path,DateAdded,ImageThumb,ImageFull) values ('$Caption','".$_REQUEST['GalleryID']."','$ImageStatus','$fileName', '$file_size', '$fileType', '$filePath','$DateAdded','$ImageThumb','$ImageFull')"; $execute = mysql_query($sql, $fetcolleges) or die(mysql_error()); if($execute){ mysql_close($fetcolleges); //header("Location: galleryImages_setup.php"); } } ?> ================== Can you explain more about what you mean? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 27, 2007 Share Posted November 27, 2007 First check your folder path is correct or not, I see you have defined your upload directory twice, and if it is online you must give write permission to that folder i.e. chmod 777 $uploadDir = '../photogalleries/'; Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted November 28, 2007 Share Posted November 28, 2007 And I also told you to use code tags. That will help so we don't have to scroll through 2 pages of code, use a code box and it will cut it off to say, 15 lines, then scroll the rest in a div box, it also formats it putting spaces in properly. Don't just plant your code right on the board. Quote Link to comment Share on other sites More sharing options...
Lumio Posted November 29, 2007 Share Posted November 29, 2007 [.code]your code[./code] (without dots) gets to your code . Please never forget. I don't want to help if there is no good overview. Quote Link to comment Share on other sites More sharing options...
9911782 Posted March 7, 2008 Author Share Posted March 7, 2008 I just wanted to thenk you all for your help. Quote Link to comment 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.