iphone jquery手机下载图片

iphone jquery手机下载图片,iphone,image,jquery-mobile,download,Iphone,Image,Jquery Mobile,Download,我在jquerymobile上有一个移动站点,它展示了图库。有一个按钮,当点击它应该下载当前的图像。 它在android和桌面浏览器中运行良好,使用小型服务器端php脚本。 但在iphone中,它只是在新标签中打开用户的图像。是的,我知道,你可以很容易地下载图像只需长时间点击,但很好。我不是想要这个的人) 脚本: <?php $file = $_GET['f']; $file = "images/com_product/product/large/".$file; download_fi

我在jquerymobile上有一个移动站点,它展示了图库。有一个按钮,当点击它应该下载当前的图像。 它在android和桌面浏览器中运行良好,使用小型服务器端php脚本。 但在iphone中,它只是在新标签中打开用户的图像。是的,我知道,你可以很容易地下载图像只需长时间点击,但很好。我不是想要这个的人)

脚本:

<?php

$file = $_GET['f'];
$file = "images/com_product/product/large/".$file;
download_file($file);

function download_file( $fullPath ){

  // Must be fresh start
  if( headers_sent() )
    die('Headers Sent');

  // Required for some browsers
  if(ini_get('zlib.output_compression'))
    ini_set('zlib.output_compression', 'Off');

  // File Exists?
  if( file_exists($fullPath) ){

    // Parse Info / Get Extension
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);

    // Determine Content Type
    switch ($ext) {
      case "gif": $ctype="image/gif"; break;
      case "png": $ctype="image/png"; break;
      case "jpeg":
      case "jpg": $ctype="image/jpg"; break;
    }

    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: $ctype");
    header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".$fsize);
    ob_clean();
    flush();
    readfile( $fullPath );

  } else
    die('File Not Found');

}
?>

我知道这有点晚了,但请将此脚本放在jQuery Mobile对我有用之前:

 $(document).bind("mobileinit", function(){
          $.mobile.ajaxEnabled = false;
   }); 

我的第一个猜测是,iOS不支持这一点。由于它没有公共文件系统,safari将只显示已知的文件类型。未知的文件类型将不起任何作用。