Reputation: 2928
I have this anchor tag as below:
<a className="badge-link" href="./download/myapp-v1.1.0.apk" download="myapp-v1.1.0.apk">
<img src="img/download-apk.png" alt=""/>
</a>
Just want to clarify that the apk file & website is hosted at a server and I'm downloading the file from there.
The download works on PC but on mobile it gets stuck at downloading status forever.
It doesn't show download progress at all.
I've tried closing the download manager & clearing its cache for android but I still get the same result.
How do I make this download work on android/iphone? Or is there any other alternatives?
Upvotes: 0
Views: 6342
Reputation: 1098
Issue seems to be with the path u specified in the href. Try giving absolete path like
<a className="badge-link" onclick="startDownload('http://somedomain.com/somefolder/somefile')" download="myapp-v1.1.0.apk"> <img src="img/download-apk.png" alt=""/> </a>
//Js to open in the same tab
<script>function startDownload(url) { window.location.href = url; }
</script>
On the HTTP Response where you are returning the file, ensure the content disposition header looks like:
Content-Disposition: attachment; filename=filename.extesion;
Check this for more about content wiki-disposition
Just to test give some third party link first later try with yours
Upvotes: 2
Reputation: 1272
Try this
<a className="badge-link" href="http://somedomain.com/download/myapp-v1.1.0.apk" download="myapp-v1.1.0.apk">
<img src="img/download-apk.png" alt=""/>
</a>
Upvotes: 0
Reputation: 1272
I think in your pc you have that apk file on the project folder, but in your mobile and also in your project folder that apk file is missing. And also you can try this code
<a className="badge-link" href="download/myapp-v1.1.0.apk" download>
<img src="img/download-apk.png" alt=""/>
</a>
Upvotes: 0
Reputation: 99
I think it's because when you're testing on PC, you have the apk inside your project directory. But you don't have it on mobile.
Upvotes: -1