Jump to content

Recommended Posts

is there a way to use php, or some other coding, to make all pictures in a certain folder display as:

 

<a href="directory here" title="title" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a>

 

 

for example.

 

so if there were two pictures, it would display them as:

 

<a href="directory here" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a>

 

<a href="directory2 here" target="_blank"><img src="source2 here" width="570" height="270" alt="Slide 3"></a>

 

etc. I do not want to use a database with these please.

Edited by searls03
Link to comment
https://forums.phpfreaks.com/topic/269441-multiple-file-upload/
Share on other sites


$dir = "path/to/directory/*";
foreach(glob($dir) as $file){ 
if (filetype($file)== 'file'){//only displays files no subdirectorys
echo "<a href='http://www.google.com' target='_blank'><img src='".$file."' width='570' height='270 alt='slide' /></a><br />";
}//close file check

}//close foreach

Edited by cmb

If you want to make sure it returns images only, use: (using cmb's code).

$dir = "path/to/directory/*.[pPjJgG][nNpPiI][gGfF]"; //case insensitive, gets only jpg, JPG, png, PNG, gif, GIF files.
foreach(glob($dir) as $file){ //only displays files no subdirectorys
echo "<a href='http://www.google.com' target='_blank'><img src='".$file."' width='570' height='270 alt='slide' /></a><br />";
}//close file check

}//close foreach

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.