הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   שאלה ב PHP (https://hosts.co.il/forums/showthread.php?t=47218)

X-T 09-06-07 18:35

שאלה ב PHP
 
אהלן, יש לי "מערכת גלריות" שהכנתי ואני רוצה שלכל התמונות שנמצאות בתיקיה ספציפית ,
את הקוד כבר הכנתי אבל אני רוצה שהוא "ירוץ" באופן אוטומטי על כל הקבצים שבתיקיה....

הכיצד ניתן לעשות זאת?

meshuga 09-06-07 18:53

opendir תהנה, יש לך שם דוגמא..
השימוש גם מחייב שימוש בreaddir.

X-T 09-06-07 19:07

אני אמור לרוץ על זה עם לולאה?

חיים 09-06-07 19:16

יש לך הסבר אתה עושה לולאת while ואז אתה קורא לכל קובץ ועושה עלייו את הפעולות הרצויות יש םש הסבר על כל הפקודות וגם דוגמה יש שם

BlueNosE 09-06-07 19:36

פועל בכל שרת:
glob
וזה גם ניתן לבחירה יותר ממוקדת. זאת לולאה אוטומטית.

X-T 09-06-07 19:48

שגיאה בקוד הבא:
PHP קוד:

$logofiles="logo.png";
$wh "upload/";
$dir  opendir($wh);

if (
is_dir($wh)) {
    if (
$dh opendir($wh)) {
        while ((
$file readdir($dh)) !== false) {
            list(
$w,$h)=getimagesize($logofiles);
            list(
$wsh,$hw)=getimagesize($wh);
            
$image imagecreatefromdir($wh);
            
$logofileimagecreatefromdir($logofiles);  
            
imagecopymerge ($image$logofile, ($wsh-$w), ($hw-$h), 00$w$h,100);
            
imagegif ($image,$wh);
        }
        
closedir($dh);
    }


השגיאה:
ציטוט:

Warning: getimagesize() [function.getimagesize]: Read error!
Fatal error: Call to undefined function: imagecreatefromdir()

meshuga 09-06-07 20:02

ציטוט:

נכתב במקור על ידי X-T (פרסם 496224)
שגיאה בקוד הבא:
PHP קוד:

$logofiles="logo.png";
$wh "upload/";
$dir  opendir($wh);
 
if (
is_dir($wh)) {
    if (
$dh opendir($wh)) {
        while ((
$file readdir($dh)) !== false) {
            list(
$w,$h)=getimagesize($logofiles);
            list(
$wsh,$hw)=getimagesize($wh);
            
$image imagecreatefromdir($wh);
            
$logofileimagecreatefromdir($logofiles);  
            
imagecopymerge ($image$logofile, ($wsh-$w), ($hw-$h), 00$w$h,100);
            
imagegif ($image,$wh);
        }
        
closedir($dh);
    }


השגיאה:

שמע הקוד שלך ממש מלא שגיאות..
א. אין כזאת פונקציה imagecreatefromdir לא יודע מאיפה המצאת אותה...
ב. בתוך הלולאה, הקובץ שלך הוא $file ולא $wh, $wh זה הנתיב לתקייה של התמונות..
ג. אף פעם לא ניסיתי, אבל אני כמעט בטוח, אתה לא יכול להדפיס מספר תמונות באותו דף..
ד. למה עשית את המשתנה $dir

X-T 09-06-07 20:07

ציטוט:

נכתב במקור על ידי meshuga (פרסם 496234)
שמע הקוד שלך ממש מלא שגיאות..
א. אין כזאת פונקציה imagecreatefromdir לא יודע מאיפה המצאת אותה...
ב. בתוך הלולאה, הקובץ שלך הוא $file ולא $wh, $wh זה הנתיב לתקייה של התמונות..
ג. אף פעם לא ניסיתי, אבל אני כמעט בטוח, אתה לא יכול להדפיס מספר תמונות באותו דף..
ד. למה עשית את המשתנה $dir

קצת תיקונים בהקשר למה שאמרת
PHP קוד:

$logofiles="logo.png";
$wh "upload/";
if (
is_dir($wh)) {
    if (
$dh opendir($wh)) {
        while ((
$file readdir($dh)) !== false) {
            list(
$w,$h)=getimagesize($logofiles);
            list(
$wsh,$hw)=getimagesize($file);
            
$image imagecreatefromdir($file);
            
$logofileimagecreatefromdir($logofiles);  
            
imagecopymerge ($image$logofile, ($wsh-$w), ($hw-$h), 00$w$h,100);
            
imagegif ($image,$file);
        }
        
closedir($dh);
    }


Same errors...

meshuga 09-06-07 20:10

ציטוט:

נכתב במקור על ידי X-T (פרסם 496242)
קצת תיקונים בהקשר למה שאמרת
PHP קוד:

$logofiles="logo.png";
$wh "upload/";
if (
is_dir($wh)) {
    if (
$dh opendir($wh)) {
        while ((
$file readdir($dh)) !== false) {
            list(
$w,$h)=getimagesize($logofiles);
            list(
$wsh,$hw)=getimagesize($file);
            
$image imagecreatefromdir($file);
            
$logofileimagecreatefromdir($logofiles);  
            
imagecopymerge ($image$logofile, ($wsh-$w), ($hw-$h), 00$w$h,100);
            
imagegif ($image,$file);
        }
        
closedir($dh);
    }


Same errors...

לא התייחסת ל-א' שכתבתי...
ציטוט:

א. אין כזאת פונקציה imagecreatefromdir לא יודע מאיפה המצאת אותה...

וגם אחרי זה לא בטוח שזה יעבוד, ראה סעיף ג'.

X-T 09-06-07 20:14

OK הקוד עכשיו כזה:
PHP קוד:

$logofiles="logo.png";
$wh "upload/";
if (
is_dir($wh)) {
    if (
$dh opendir($wh)) {
        while ((
$file readdir($dh)) !== false) {
            list(
$w,$h)=getimagesize($logofiles);
            list(
$wsh,$hw)=getimagesize($file);
            
imagecopymerge ($image$logofile, ($wsh-$w), ($hw-$h), 00$w$h,100);
            
imagegif ($image,$file);
        }
        
closedir($dh);
    }


שגיאות משורה 8 ו 10 =\ איך אני מתקדם מפה?


כל הזמנים הם GMT +2. הזמן כעת הוא 12:20.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ