允许访问者下载我的网站中的文件(php、javascript、html)
在我的网站上,我想允许访问者下载图片。 我用以下方式显示图片允许访问者下载我的网站中的文件(php、javascript、html),php,zip,Php,Zip,在我的网站上,我想允许访问者下载图片。 我用以下方式显示图片 <a href="" ><img src = "picture" .../> </A> 当访问者点击链接时,如何开始下载图片 第二个问题,若我有很多链接,我如何在一个目录中压缩图片并允许压缩文件的下载?设置apache设置:: 以下是下载文件的PHP <?php $rootPath = "files/"; $filename = "output.txt"; $orig_filenam
<a href="" ><img src = "picture" .../> </A>
当访问者点击链接时,如何开始下载图片
第二个问题,若我有很多链接,我如何在一个目录中压缩图片并允许压缩文件的下载?设置apache设置::
以下是下载文件的PHP
<?php
$rootPath = "files/";
$filename = "output.txt";
$orig_filename = $_POST[ 'filename' ];
$filename = $rootPath . $filename;
$filesize = filesize( $filename );
if ( $fd = fopen( $filename, "r" ))
{
header( "Content-type: application/octet-stream" );
header( "Content-Disposition: filename=\"$orig_filename\"" );
header( "Content-length: $filesize " );
header( "Cache-control: private" );
while( !feof( $fd ))
{
$buffer = fread( $fd, 1024 );
echo $buffer;
}
fclose( $fd );
}
exit;
?>
但这仅适用于现代浏览器……可能重复:这将在navogator中打开图像!!我希望它在popin和下载!我要测试一下,我会回来的
<a href="/path/to/image" download="ImageName" title="ImageName">
<img src="/path/to/image" alt="ImageName">
</a>