douqian4411 2019-05-24 20:40
浏览 91

PHP下载警告:“通常不下载,可能很危险”

I need create zip file and download it, after delete, but after downloading Google Chrome give warning "is not commonly downloaded and may be dangerous" if i go to direct link and download file its working fine but download in php give warning. How i can fix it ?

$zip_file = public_path().'/storage/file.zip';

$zip = new ZipArchive();
    if ( $zip->open($zip_file, ZipArchive::CREATE) !== TRUE) {
    exit("message");
    }
$zip->addFromString(basename('file.cs'),$plugin);
ob_clean();
ob_end_flush();

header("Cache-Control: public");
header('Content-Type: application/zip');
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=\"".basename($zip_file)."\"");
header("Content-length: " . filesize($zip_file));
header("Pragma: no-cache"); 
header("Expires: 0"); 
readfile($zip_file);
unlink($zip_file);
exit();
  • 写回答

1条回答 默认 最新

  • duanquan4451 2019-05-24 21:37
    关注

    Be sure zip is a valid MIME type, you can add the following to your htaccess file if you are using Apache:

    AddType application/zip .zip
    

    If that does not work for you, this support document from Google says there is a way to ask for a review in the search console; others have reported using it with success:

    https://support.google.com/webmasters/answer/3258249

    评论

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号