Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Incompatible with Apple Devices

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Incompatible with Apple Devices

Postby Parrot » Wed Jun 05, 2013 5:51 pm

I've set up code to allow users to purchase mp3 files. I keep the files in a non web-accessible directory and use a script that verifies that the user is logged in and has purchased the file before it lets them download it. Once the user has been validated it outputs the header specifying a file transfer and sends the file.

The problem is that iPhone and iPad users are complaining that their devices won't download the file. It works for everybody else.

Is there a fix for this? Some alternate way of doing this that would work on an Apple mobile device?

This is the relevant part of the code

Code: Select all
if(file_exists($path))
{   
   header("Pragma: public");
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: public");
   header("Content-Description: File Transfer");
   header("Content-Type: " . $mm_type);
   header("Content-Length: " .(string)(filesize($path)) );
   header('Content-Disposition: attachment; filename="'.basename($path).'"');
   header("Content-Transfer-Encoding: binary\n");
   
   readfile($path); // outputs the content of the file
}
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Incompatible with Apple Devices

Postby johnj » Wed Jun 05, 2013 8:24 pm

give this a try - remove header("Cache-Control: public"); and run the code in apple devices again.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Incompatible with Apple Devices

Postby johnj » Wed Jun 05, 2013 8:25 pm

what is the value for content type, i mean for $mm_type?
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Incompatible with Apple Devices

Postby Parrot » Wed Jun 05, 2013 8:32 pm

johnj wrote:what is the value for content type, i mean for $mm_type?


application/octet-stream
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Incompatible with Apple Devices

Postby johnj » Wed Jun 05, 2013 8:59 pm

check if application/mp3 will work.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Incompatible with Apple Devices

Postby Parrot » Wed Jun 05, 2013 9:05 pm

johnj wrote:check if application/mp3 will work.


Wouldn't it more properly be audio/mpeg3?
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm

Re: Incompatible with Apple Devices

Postby johnj » Wed Jun 05, 2013 9:07 pm

things you can try;
do a die() or exit() after readfile

use file_get_contents and then echo it instead of using readfile.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Incompatible with Apple Devices

Postby johnj » Wed Jun 05, 2013 9:08 pm

Yes, you can try audio/mpeg (not mpeg3)
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Incompatible with Apple Devices

Postby Parrot » Wed Jun 05, 2013 9:10 pm

johnj wrote:Yes, you can try audio/mpeg (not mpeg3)


Why not mpeg3?
Parrot
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Oct 01, 2012 10:17 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron