Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

readfile support for iOS to download!

General discussions related to php

Moderators: macek, egami, gesf

readfile support for iOS to download!

Postby elvis » Wed Dec 26, 2012 6:46 pm

Hi all,
My php using readfile, not be able to download in the iOS and Android, is there a way to solve?
The following is my program:

$file_extension = strtolower(substr(strrchr($filename,'.'),1));
switch( $file_extension ){
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt":
case "pptx":
$ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}

$expires = 60*60*24*14;
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
header('Accept-Ranges: bytes');
header('Cache-Control: no-cache');
header('Content-Description: File Transfer');
header("Content-type: $ctype");
header("Content-Disposition: attachment; filename=\"".$encoded_filename."\";");
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($download_path));
ob_end_flush();
readfile($download_path);


thanks all!
elvis
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Dec 26, 2012 6:30 pm

Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

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

cron