
03-01-2008, 18:34
|
|
|
|
חבר מתאריך: 10.10.04
הודעות: 224
|
|
|
הסתדרתי. תודה.
הבעייה היתה בפיצול(/ץ) הנתיב.
היות ועברתי לספריה שהייתי צריך לסגת בה לאחור על ידי ../
והפעלתי בדיקה שמפצלת את הנתיב ולוקחת את הסיומת אחרי הנקודה הראשונה (כי בדרך כלל יש רק נקודה אחת בשם)
פשוט תיקנתי שהבדיקה תיעשה למקום הרביעי במערך במקום למקום הראשון
בכל מקרה, הנה הקוד.
קוד PHP:
$target = '../photos/'.$pictures_folder .'/'; $name = $target . $_FILES["file_name"]["name"]; // '../photos/all_kind/picturename.jpg' function createthumb($name,$filename,$new_w,$new_h) { // pay attention how many '.' there are till the 'jpg' string !!!! $system=explode('.',$name); if (preg_match('/jpg|jpeg/',$system[3])){ $src_img=imagecreatefromjpeg($name); } if (preg_match('/png/',$system[3])){ $src_img=imagecreatefrompng($name); } // ----------------------------------------------------- $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } // ----------------------------------------------------- $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y); // ----------------------------------------------------- if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } // ----------------------------------------------------- createthumb($name,'../photos/thumbs/tn_'.$_FILES["file_name"]["name"],80,80);
|