私はアプリケーションを作成します。これは、ファイル形式のサーバーをダウンロードできます。
このコードを使用 >>>
public int startDownload(String url, String filename) {
// create url connector
URL u;
byte[] buffer = new byte[1024];
try {
u = new URL(url + filename);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
InputStream in = c.getInputStream();
m_lMaxDownloadSz = c.getContentLength();
FileOutputStream f = new FileOutputStream(new File(FILE_PATH, filename));
m_bCancelDownload = false;
m_lCurrentDownloadSz = 0;
int len = 0;
while ((len = in.read(buffer, 0, 1024)) > 0) {
// if download is canceled.
if (m_bCancelDownload) {
f.close();
c.disconnect();
return FILE_DOWNLOAD_CANCELED;
}
if (knot++ >= PROGRESS_STEP) {
knot = 0;
myProgressDialog.setProgress(GetDownloadStatus());
}
f.write(buffer, 0, len);
m_lCurrentDownloadSz += len;
}
f.close();
c.disconnect();
} catch (Exception e) {
return FILE_DOWNLOAD_FAILED;
}
if (GetDownloadStatus() == 100) {
return FILE_DOWNLOAD_FINISHED;
} else {
return FILE_DOWNLOAD_FAILED;
}
}
そして、PHP強制ダウンロードで使いたいのですが、うまくいきません。通常、「app/aaa.apk」のようなファイルパスで使用するとうまくいきます!、そして、「php/forcedl.php」のようなPHPファイルに変更しても機能しません。
php force download を使用する必要がありますが、どのように使用すればよいですか?
ps。私は英語のスキルがほとんどありません。なぜなら、英語は私の主要な言語ではないからです
ありがとうございました