Jump to content

Multiple File Upload


searls03

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.

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.