PHP: Download script file not working on iPad

I have a downloaded script file that I wrote that reads the files below public_html and allows the user to download them after checking if the user is registered and that the file is a valid file for them. download.

The problem that I recently ran into is that on the iPad it just does nothing when the link is clicked.

Sample download file code after performing all checks:

header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/msword"); header("Content-Disposition: attachment; filename=\"file.doc\";" ); header("Content-Length: 50688"); readfile(SITE_PATH .'/files/file.doc'); 

This script has been tested and tested on PC, Mac and Linux computers in multiple browsers (FF, Opera, IE6-9, Chrome, Safari) and everything seems to work fine, so this should be something the iPad does otherwise .

I would suggest that this is because the iPad does not have the file structure as such for downloading files, but I'm not sure.

Has anyone encountered this problem before? If so, is there a fix?

+6
source share
3 answers

iOS Safari does not support file downloads.

Update: But if you want to open .doc files on iPad, then yes ... you can do it ...

use the following -

 header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/msword"); readfile('file.doc'); 

The only difference in your code and mine is to delete the title for the attachment. Just delete this title -

 header("Content-Disposition: attachment; filename=\"file.doc\";" ); header("Content-Length: 50688"); 

In fact, you can check the client operating system if the operating system is iOS, and then do not add a header to download, as it is

 header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/msword"); if (!Operating_System_Is_IOS) { header("Content-Disposition: attachment; filename=\"file.doc\";" ); header("Content-Length: 50688"); } readfile(SITE_PATH .'/files/file.doc'); 
+11
source

Apple has blocked iOS devices so that you cannot access the file structure. Thus, they turned off file downloads.

0
source

You can force the user to insert the link (with the identifier of a limited time in it due to login ...) in any third-party application, for example, GoodReader. Or just let them view the doc file in the browser.

-1
source

Source: https://habr.com/ru/post/905899/


All Articles