Wie download-Datei auf android mit PHP force-download

Ich einen Antrag stellen , dies kann die download-Datei Formular-server.

verwenden Sie diesen code >>>

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;
}

}

und ich will mit PHP force-download , aber es funktioniert nicht , gewöhnliche it-Einsatz mit dem Datei-Pfad wie in 'app/aaa.apk' es funktioniert! und ich auf die PHP-Datei wie "php/forcedl.php' es funktioniert nicht.

Ich muss mit php force-download, Wie kann ich Sie verwenden?

ps. ich habe wenig der englischen Sprache Fähigkeit , verursachen die englische Sprache ist nicht meine Hauptsprache

danke

Was passiert, wenn Sie versuchen zu upen diese url im browser?
ich öffne www.xxx.com/x.php im android-browser , zeigen, Einreichen, um die Datei herunterladen.apk-ps. in der Datei php - > header forcedownload, um eine apk-Datei

InformationsquelleAutor chawanan | 2011-09-08

Schreibe einen Kommentar