0

I've been trying for a couple of days to solve this issue but nothing so far.

Nothing happens when a "Download" button gets pressed.

No error, no message, just nothing at all.

The action is called by an input:

<input type="submit" name="cmdfiledownload" id="cmdfiledownload" class="button" >

A validator checks if the file has already been generated, and in case creates it before sending it back:

// Process download
if(is_file($filepath)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($filepath).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($filepath));
    ob_clean();
    flush(); // Flush system output buffer
    readfile($filepath);
    exit;
}

So, there is never a file URL exposed anywhere on the page.

Its location is NOT into public_html so it can't be reached otherwise.

The system works perfectly in a normal browser (Chrome mobile, AdBlock Beta).

I just can't make it work into inappbrowser.

Uploads work without issues.

  • Why on earth would you use inappbrower when you're in a webview already? – Eric Jan 23 '20 at 15:17
  • Well, mostly because I'm building it this way in case it might be useful later. Anyway, I tried running it without inappbrowser and just with window.location.replace("someplace.html") And it's the same thing. Could you please elaborate a bit more? – Lorenzo Maglio Jan 23 '20 at 15:32
  • What does cmdfiledownload do? There is no JS code for your button – Eric Jan 23 '20 at 15:48
  • It submits a form and a php validator (the code I posted) serves the file, but since it is a forced download it uses the headers. It doesn't use js at all, just the browser capabilites. But while it works in a browser, it doesn't in app. – Lorenzo Maglio Jan 23 '20 at 15:58
  • https://stackoverflow.com/questions/41129399/cordova-download-from-url-to-android-download-folder – Eric Jan 23 '20 at 22:55
  • Does this answer your question? [cordova: download from url to android download folder](https://stackoverflow.com/questions/41129399/cordova-download-from-url-to-android-download-folder) – Eric Jan 23 '20 at 22:56
  • Thanks for the link - sadly, I had already checked it and it can't handle my issue. The fact is that the zip file isn't into public_html, but in a parallel dir into the same domain. I can't use codeblocks in comment, so no graphic help here. Anyway, since the file is not into public, no js can reach it. But what I really don't understand is why it works in a browser but not into a webview! – Lorenzo Maglio Jan 24 '20 at 16:00

0 Answers0