duanhan8757 2011-12-08 02:33
浏览 32

在php中的Iphone web app下载附件功能

I have a iphone app which use uiwebview to include a mobile site, the mobile site is developed in PHP, some of the page is allow people to download some attachments by using header force download, since the file will be convert to some binary and finally output as a download file by made use of php header function, im wondering will it be work in iphone app uiwebview too?

  • 写回答

1条回答 默认 最新

  • dongxiequ3724 2012-08-13 16:58
    关注

    This site provides a script that they say works.

    Here's my code sending vcard as attachement with no message:

        //create a boundary string. It must be unique
        $random_hash = md5(date('r', time())); $alt_random_hash = md5(date('r', time()+1)); 
    
        //read the atachment file contents into a string, 
        //encode it with MIME base64, 
        //and split it into smaller chunks 
        $attachment = (chunk_split(base64_encode(file_get_contents($url))); 
        $filename = "Alain_Leblanc.vcf";    
    
        // Write the email message (which will become an attachement)
        $headers .= "
        MIME-Version: 1.0 
        From: info@AlainLeblancAssurances.ca 
        Reply-To: info@AlainLeblancAssurances.ca 
        Content-Type: text/x-vcard; charset=utf-8; name=$filename; boundary=$random_hash  
        Content-Disposition: attachment; filename=$filename 
        Content-Transfer-Encoding: base64
    
        --$random_hash 
    
        $attachment
    
        --$random_hash-- 
        ";
    
        //send the email  
        $mail_sent = @mail($_POST['userEmail'], "Fiche contacts d'Alain Leblanc", "", $headers); 
        // display email result in browser
        echo $mail_sent ? "rand: ".$random_hash ."<br/>Alt: ".$alt_random_hash."<br/>".$headers : "Mail failed";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集