2011-12-08 3 views
0

私はモバイルサイトを含むためにuiwebviewを使用するiphoneアプリを持っています。モバイルサイトはPHPで開発されていますが、一部のページはヘッダ強制ダウンロード、ファイルはいくつかのバイナリに変換され、最終的にphpヘッダー関数を使ってダウンロードファイルとして出力されるので、im iphone app uiwebviewでも動作するのだろうか?Iphoneウェブアプリケーションのダウンロード機能をPHPで

+1

PHPスクリプトが正しく関連するヘッダとバイナリデータを出力した場合、それは消費者がある違いはありません。その時点で、ブラウザ(またはiPhoneアプリ)がダウンロードを正しく処理できるかどうかだけが懸念されます。私のiPhoneは、伝統的な意味でサファリのデバイスにファイルをダウンロードできないことを知っています...もしそれらがPDFファイルでないなら。 – rdlowrey

答えて

0

このsiteは、動作するスクリプトを提供します。

ここでメッセージなしで添付ファイルとしてのvCardを送る私のコードです:

//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: [email protected] 
    Reply-To: [email protected] 
    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"; 
関連する問題