Hi i'm working on a text editor for a CMS i have a fuction where you can upload an image and if it is uploaded the image is put into the text. This always worked great without resize but i want the images to be resized then saved and then put in the text. The script I'm using for this is:
But this is not working, i think i'm forgetting something but i don't know what.. Can someone help me with this??PHP Code://change image size---------------------------------------------
$image_type = strstr($file_name, '.');
//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
case '.jpg':
$source = imagecreatefromjpeg($file_name);
break;
case '.JPG':
$source = imagecreatefromjpeg($file_name);
break;
case '.png':
$source = imagecreatefrompng($file_name);
break;
case '.PNG':
$source = imagecreatefrompng($file_name);
break;
case '.GIF':
$source = imagecreatefromgif($file_name);
break;
case '.gif':
$source = imagecreatefromgif($file_name);
break;
}
//
list($width, $height) = getimagesize($file_name);
$propBigH = $height/$maxHeight;
$propBigW = $width/$maxWidth;
//
if ($width > $maxWidth){
$heightBig = $height/$propBigW;
$widthBig = $maxWidth;
}
else{
$heightBig = $height;
$widthBig = $width;
}
//
$bigImg = imagecreatetruecolor($widthBig, $heightBig);
imagecopyresized($bigImg, $source, 0, 0, 0, 0, $widthBig, $heightBig, $width, $height);
//---------------------------------------------------------------
$result = imagejpeg($bigImg, $file_path, $qualityBig);
if (!chmod($file_path,0755))
$message = "change permission to 755 failed.";
else{
echo "<script language='JavaScript'>window.location.href = \"uploadOne.php?loaded='yes'&fileName='http://".$_SERVER['HTTP_HOST']."/CMS/img/files/".$file_name."'\";</script>";
"Something is wrong with uploading a file.";*/
}
I added the full script to this post as zip..
Thanks in advance..


Reply With Quote
Bookmarks