0

I have a PHP script which is downloading file after it is created. Everything is working correctly when using PC but when I want to load same script on my iPad for example I can't download it. I'm getting error that file is broken.

What could be the problem?

My headers in PHP file:

header('Content-Description: File Transfer'); 
header("Content-type: application/ms-word");
header("Content-Disposition: attachment;Filename=offer.doc");
Steve Byrne
  • 1,320
  • 1
  • 16
  • 29
user123_456
  • 5,635
  • 26
  • 84
  • 140
  • Are you sure that the file format is supported on Ipad? Also you may get more help if you change your title to state that the file is broken rather than just saying "doesn't work", because the file it's self is downloading. It is just broken when it's downloaded. – Steve Byrne Jul 20 '13 at 09:48
  • 1
    What does `offer.doc` contain? Is it an actual, native, binary Word file, or is it a HTML-based fake .doc? – Pekka Jul 20 '13 at 09:54
  • @Pekka웃 it as html-based – user123_456 Jul 20 '13 at 10:02
  • Then in that case I believe Pekka's answer should work :) Good luck with your project! – Steve Byrne Jul 20 '13 at 10:04

1 Answers1

1

I have a PHP script which is downloading file after it is created.

My bet is you're using HTML to create the file, and giving it a .doc extension to make it look like a Word document.

While this is totally okay and supported by all versions of Word AFAIK, a 3rd party viewer program like on an iPad may be more strict. A HTML based file is technically not a Word document, and the viewer may not be equipped to parse it accordingly.

You may need to resort to generating a real .doc file.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • 1
    you are correct. I found this answer `http://stackoverflow.com/questions/8849197/php-download-file-script-not-working-on-ipad`, so the next step would be to save the file on the server with a `doc` extension and then open it on ipad...any ideas? – user123_456 Jul 20 '13 at 10:04
  • you know funny thing is that I tried something similar with PHPDocx library...and the file normally downloaded on my iPad...but as PHPDocx has limited free features I decided to make my own html represented ms-word file. I'll try to save the file and then open it. – user123_456 Jul 20 '13 at 10:08
  • @user you'll have to convert the file into an actual .doc somehow, there'll be no way around that. Maybe PHPDocX can help; I know for a fact the OpenOffice can do this, but for that you'd need a dedicated server with OpenOffice running. – Pekka Jul 20 '13 at 10:10