PHPを使用して、ユーザーが入力した情報に基づいてApacheサーバー上のアプリケーションをコンパイルし、readfile()
メソッドを使用してアプリケーションを提供しています。
私が直面している問題は、実際にアプリケーションをダウンロードする代わりに、.apkファイルがテキストファイルとして開かれていることです。
PHPを使用してサーバーからAPKをダウンロード中のガベージ出力
PHPコードにアンドロイドアプリのmimeタイプを追加しました。
私のPHPコードは次のとおりです。
<?php
echo "Please wait while the app is being generated, it can take around 10 minutes for the build to finish.The completed app will be mailed to you ";
if(isset($_POST['timestamp']))
{
$uid = $_POST['timestamp'];
exec("sudo python /var/www/html/appgenserver.py $uid");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.android.package-archive");
header("Content-Transfer-Encoding: Binary"); //Adding or removing this hass no effect
header('Content-Disposition: attachment; filename="Foo.apk"');
ob_clean();
flush();
readfile("/var/www/html/".$uid."/releaseapk.apk");
exit();
}
?>
任意の助けをいただければ幸いです。
はあまりにもecho文をコメントアウトしています。しかし、同じエラーです。 –
http://php.net/manual/en/function.readfile.phpのこのページの例の1つから始め、それを動作させてから、一度に1つずつ追加します。 –
ありがとう、 しかし別の方法で修正して質問に答えました –