title: How to download file on android with PHP force download
body: <p>I make an application , this can download file form server.</p>
  
  <p>use this code >>></p>
  
  <pre><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)) &gt; 0) {
  
      // if download is canceled.
      if (m_bCancelDownload) {
        f.close();
        c.disconnect();
        return FILE_DOWNLOAD_CANCELED;
      }
      if (knot++ &gt;= 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;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and I want to use with PHP force download , but it not work , ordinary it use with file path like 'app/aaa.apk' it work! ,and I change to PHP file like 'php/forcedl.php' it not work.</p>
  
  <p>I needs to use with php force download, How do I use?</p>
  
  <p>ps. i have little english language skill , cause english language is not my main language</p>
  
  <p>thank you</p>