0

次のサイトに画像があります。

www.blah.com/gallery/gallery/2244.jpg

この URL を直接入力すると、画像が表示されます。

今、画像(およびその他)を表示したい小さなギャラリーがありますが、次のコードを使用すると表示されません。

$files = glob("/home/mysite/public_html/gallery/gallery/*.*"); 

for ($i=1; $i<count($files); $i++) 
{

 $num = $files[$i];

 echo '<a class="fancybox-effects-a" rel="gallery" href="'.$num.'">';
 echo '<img src="'.$num.'" class="gallery_img" alt=""></a>'; 

 } 

画像は次のようにエラーなくアップロードされました ( http://www.verot.net/php_class_upload.htmを使用):

if(isset($_FILES['image'])){

include('/home/mysite/php/lib/img_upload/class.upload.php');

// retrieve eventual CLI parameters
$cli = (isset($argc) && $argc > 1);
if ($cli) {
    if (isset($argv[1])) $_GET['file'] = $argv[1];
    if (isset($argv[2])) $_GET['dir'] = $argv[2];
    if (isset($argv[3])) $_GET['pics'] = $argv[3];
}

// set variables
$dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test');
$dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest);

if (!$cli) {

// ---------- IMAGE UPLOAD ----------

$handle = new Upload($_FILES['image']);

if ($handle->uploaded) {

    $handle->image_resize            = true;
    $handle->image_ratio_x           = true;
    $handle->image_y                 = 500;

    $handle->Process('/home/mysite/public_html/gallery/gallery/');

    // we check if everything went OK
    if ($handle->processed) {
        // everything was fine !

        $success .= 'Image uploaded to the gallery successfully!';

    } else {
        // one error occured
        $error .= '<li>file not uploaded to the wanted location';
        $error .= '<li>Error: ' . $handle->error . '';
    }

    // we now process the image a second time, with some other settings
    /******************************/
    // produce thumbnails
    /*****************************/
    $handle->image_resize            = true;
    $handle->image_ratio_x           = true;
    $handle->image_y                 = 120;
    $handle->image_reflection_height = 50;
    $handle->image_reflection_opacity = 90;
    $handle->image_convert = 'png';

    $handle->Process('/home/mysite/public_html/gallery/gallery/thumbs/');

    // we check if everything went OK
    if ($handle->processed) {
        // everything was fine !
        $success .= '<p>Thumbnail created successfully, see below...';
        $success .= '<p><img src="/gallery/gallery/thumbs/' . $handle->file_dst_name . '" />';
    } else {
        // one error occured
        $error .= 'file not uploaded to the wanted location';
        $error .= '  Error: ' . $handle->error . '';
    }

    /******************************/
    // END use this if you want to produce thumbnails
    /*****************************/

    // we delete the temporary files
    $handle-> Clean();

} else {
    // if we're here, the upload file failed for some reasons
    // i.e. the server didn't receive the file
    $error .= '<li>file not uploaded on the server';
    $error .= '<li>Error: ' . $handle->error . '';
}

}

}

私はこれをまったく理解できません!

4

1 に答える 1

2

srcを画像の絶対パスに設定したようです。これを試して:

foreach (glob('/home/mysite/public_html/gallery/gallery/*.jpg') as $file) {
  $file = '/gallery/gallery/'.basename($file);
  echo '<a class="fancybox-effects-a" rel="gallery" href="'.$file.'">';
  echo '<img src="'.$file.'" class="gallery_img" alt=""></a>'; 
}
于 2012-05-29T18:36:26.843 に答える