Re: Serving a .dmg via readfile?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 25, 2012 at 9:04 PM, Tommy Pham <tommyhp2@xxxxxxxxx> wrote:
> On Wed, Apr 25, 2012 at 8:54 PM, Brian Dunning <brian@xxxxxxxxxxxxxxxx> wrote:
>> Hey all - I'm having no luck serving a .dmg from my online store. I stripped down the code to just the following to debug, but no matter what I get a zero-byte file served:
>>
>>  header('Content-Type: application/x-apple-diskimage');   // also tried octet-stream
>>  header('Content-Disposition: attachment; filename="My Cool Image.dmg"');
>>  $size = filesize('/var/www/mypath/My Cool Image.dmg');
>>  header('Content-Length: '.$size);
>>  readfile('/var/www/mypath/My Cool Image.dmg');
>>
>> This same code works for a number of other file types that I serve: bin, zip, pdf. Any suggestions? Professor Google is not my friend.
>> --
>
> Maybe file size limit somewhere?

Forgot to mention that your code doesn't check the result [1].  If it
was this instead:

header('Content-Type: application/x-apple-diskimage');   // also tried
octet-stream
header('Content-Disposition: attachment; filename="My Cool Image.dmg"');
$size = filesize('/var/www/mypath/My Cool Image.dmg');
header('Content-Length: '.$size);
if (readfile('/var/www/mypath/My Cool Image.dmg') === false) die
('Error readfile ...');

Or alternatively, use xdebug in your dev environment. ;)

HTH,
Tommy

[1] http://php.net/readfile

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux