This is pushan once again .I have a applied a code to download multiple pictures after selecting them through check boxes. the value property of the check box contains the full path of the image .The image file is not downloading here is the code snippet:
if(isset($_POST['picdnld'])) {
$picarry=$_POST['supplier_picture'];
foreach($picarry as $pic) {
$handle = fopen($pic, "r");
$filename1 = basename($pic);
$xt=pathinfo($pic, PATHINFO_EXTENSION);
$filename=$filename1;
echo $filename.'</br>';
$outhandle=fopen('image'."/".$filename,"w");
if($outhandle){
echo 'directory found'.'</br>';
} else {
echo "directory not found".'</br>';
}
while (!feof($handle)) {
$buffer=fread($handle,4096);
fputs($outhandle,$buffer);
}
}
fclose($handle);
fclose($outhandle);
}
supplier picture is the name of the checkbox whose post contains the image links.I found that $outhandle
is returning fa开发者_StackOverflow中文版lse every time. please help me to down load multiple selected images.
This is not possible the way you show. A response can generally contain only one image resource.
The most common way of doing this is to put all images into a ZIP file, and offer that for download. You could use the ZipArchive
class for that. The linked page contains a small example.
Just read the image file and before sending it to browser
set the content header before sending to browser
header ("Content-Type: image/jpeg")
.
精彩评论