![ישן](https://static.fresh.co.il/images/vBulletin/statusicon/post_old.gif)
21-11-2007, 11:01
|
![צלמית המשתמש של fcf](image.php?u=72179&dateline=1127314499) |
|
|
חבר מתאריך: 17.09.05
הודעות: 6,023
|
|
איך קוד המקור יעזור לך ... ?
לא רואים את תוכן הPHP בקוד המקור ...
אני ממש מבולבל !
תחילה אני מעלה קובץ לשרת - אל נתיב מסויים
לאחר מכן אני מפעיל את הפונקצייה על הנתיב הזה בדיוק והוא אומר לי שהתמונה הזאת היא לא תמונה ?
בכל מקרה .. הנה המקור של הדף עם השגיאות ...
קוד:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl">
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1255">
<title>הוספת גלרייה לשלב 1</title>
<link rel="stylesheet" type="text/css" href="http://uzone-il.net/includes/maincss.css">
</head>
<body>
<center><b>פרטי ההעלאה שלך</b></center><br><table align="center" width="97%" cellspacing="0" cellpadding="4" border="1" style="border-collapse: collapse;" bordercolor="gray" class="row"><tr><td bgcolor="skyblue">מספר</td><td bgcolor="skyblue">סטטוס</td><td bgcolor="skyblue">שם</td><td bgcolor="skyblue">קוד שגיאה</td></tr>upload/pictures/59.png<br />
<b>Warning</b>: imagesx(): supplied argument is not a valid Image resource in <b>/home/.osen/uzone/uzone-il.net/gallery.php</b> on line <b>144</b><br />
<br />
<b>Warning</b>: imagesy(): supplied argument is not a valid Image resource in <b>/home/.osen/uzone/uzone-il.net/gallery.php</b> on line <b>145</b><br />
<br />
<b>Warning</b>: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in <b>/home/.osen/uzone/uzone-il.net/gallery.php</b> on line <b>201</b><br />
<br />
<b>Warning</b>: imagecopyresampled(): supplied argument is not a valid Image resource in <b>/home/.osen/uzone/uzone-il.net/gallery.php</b> on line <b>203</b><br />
<br />
<b>Warning</b>: imagepng(): supplied argument is not a valid Image resource in <b>/home/.osen/uzone/uzone-il.net/gallery.php</b> on line <b>214</b><br />
<tr>
<td class="row">1</td><td><center><img src="images/theme/good.png"></center></td><td>40264027.png</td><td>---</td></tr>
</table><br><center><b><a href="http://uzone-il.net/gallery.php?guideid=31&step=1">לחץ כאן בכדי להעלות תמונות נוספות</a></b></center></body>
</html>
וכך אני מעלה את הקובץ לשרת , משנה את הרשאותיו ולאחר מכן קורא לפונקצייה לשינוי הגודל
קוד:
@copy($_FILES['userfile']['tmp_name'][$i-1], "$absolute_path/$picturesname$ext") or ($error3 = 1 and $error = 1);
chmod("$absolute_path/$picturesname$ext", 0777);
reduceImageSize("$absolute_path/$picturesname$ext","$absolute_path/$picturesname$ext",500,1000);
וזאת הפונקצייה לשינוי הגודל
קוד PHP:
function reduceImageSize($orig_file, $dest_file, $max_x, $max_y, $trim = KEEP_PROPORTIONS) {echo "$orig_file"; $image_info = getImageSize($orig_file); $orig_x = imagesx($o_im) ; $orig_y = imagesy($o_im) ; $dst_x = 0; $dst_y = 0; $src_x = 0; $src_y = 0; $dst_w = 0; $dst_h = 0; $src_w = $orig_x; $src_h = $orig_y; // calculate the image size limitations if (($orig_x < $max_x) && ($orig_y < $max_y)) { // NO SCALE !!! $dst_w = $orig_x; $dst_h = $orig_y ; } else if ($orig_y < $max_y) { // need to scale only X $dst_w = $max_x; $dst_h = round($dst_w * $orig_y / $orig_x); } else if ($orig_x < $max_x) { // need to scale only Y $dst_h = $max_y; $dst_w = round($dst_h * $orig_x / $orig_y); } else { // need to scale X and Y if ($trim == KEEP_PROPORTIONS) { $dst_w = round($max_y * $orig_x / $orig_y); // limit according to max_y and proportion if ($dst_w > $max_x){ $dst_w = $max_x; // limit according to max_x } $dst_h = round($dst_w * $orig_y / $orig_x); // limit according to max_x and proportion if ($dst_h > $max_y){ $dst_h = $max_y; // limit according to max_y $dst_w = round($dst_h * $orig_x / $orig_y); } } elseif($trim == KEEP_SIZE) { $dst_w = $max_x; $dst_h = $max_y; if ( ($orig_x / $orig_y) > 1 ) { // width is more the height $src_w = $src_h; $src_x = round( ($orig_x - $src_w) / 2); } else { // height is more then width $src_h = $src_w; $src_y = round( ($orig_y - $src_h) / 2); } } else{ return 'unknown resize option'; } } $t_im = imageCreateTrueColor($dst_w, $dst_h); imagecopyresampled( $t_im, $o_im, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); $resOK = false; switch ($image_info['mime']) { case 'image/gif': $resOK = imagegif($t_im, $dest_file); break; case 'image/jpeg': $resOK = imagejpeg($t_im, $dest_file); break; case 'image/png': $resOK = imagepng($t_im, $dest_file); break; case 'image/wbmp': $resOK = imagewbmp($t_im, $dest_file); break; default: $ermsg = $image_info['mime'].' שמירת תמונה מוקטנת נכשלה ' .$orig_file; break; } if (!$resOK) return $ermsg = 'יצירת תמונה נכשלה - ' .$orig_file; imageDestroy($o_im); imageDestroy($t_im); return isset($ermsg)? $ermsg : S_OK; }
_____________________________________
![תמונה שהועלתה על ידי גולש באתר ולכן אין אנו יכולים לדעת מה היא מכילה](https://2008-uploaded.fresh.co.il/2008/08/08/81909117.jpg)
נערך לאחרונה ע"י fcf בתאריך 21-11-2007 בשעה 11:11.
|