PHP: Download file script not working on iPad

后端 未结 3 373
长情又很酷
长情又很酷 2020-12-15 13:00

I have a file download script that I have written, which reads files from below public_html and allows the user to download them after checking to see if the user is logged

相关标签:
3条回答
  • 2020-12-15 13:34

    Apple has locked down the iOS devices so that you can't access the file structure. As such, they have disabled file downloads.

    0 讨论(0)
  • 2020-12-15 13:38

    iOS Safari does not support file download..

    Update: But if you are looking to open the .doc files on iPad then yes.. you can do that...

    use 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 I removed the header for attachment Just remove these header -

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

    Actually you can check for client operating system if operating system is iOS then don't add header for download like this -

    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');
    
    0 讨论(0)
  • 2020-12-15 13:44

    You can force the user to paste the link (with a time limited ID in it due to log in ...) into any third party app, like GoodReader. Or just let them view the doc file in the browser.

    0 讨论(0)
提交回复
热议问题