Im sure this question has been asked a lot of times before but i am using a php script to generate a url list of images in a folder.
I need to force the images to download as opposed to open within a browser window.
Im assuming its with the use of the header() function, but am having no luck with this. Im testing on IE 5.5 on win2k.
The images can have various name so would like them to D/L with their own name.
The script i am using is as follows;
- This little example prints a sorted directory
- listing, with dirs first and files afterwards.
*/
// Open current directory
if($handle = opendir(".")){
// Loop through all files
while(false !== ($file = readdir($handle))){
// Ignore hidden files
if(!preg_match("/./", $file)){
// Put dirs in $dirs[] and files in $files[]
if(is_dir($file)){
$dirs[] = $file;
}else{
$files[] = $file;
}
}
}
// Close directory
closedir($handle);
// if $dirs[] exists, sort it and print all elements in it.
if(is_array($dirs)){
sort($dirs);
foreach($dirs as $dir){
echo "<a href=\"$dir/\">$dir/</a><br />\n";
}
}
// if $files[] exists, sort it and print all elements in it.
if(is_array($files)){
sort($files);
foreach($files as $file){
echo "<a href=\"$file\">$file</a><br />\n";
}
}
}
?>
TIA
Mark