user3515257 user3515257 - 9 months ago 66
PHP Question

UC browser on force download file type is unknown

I got stuck in a very unusual problem. I am using php force download for downloading video files in my website which works fine in most browsers such as chrome firefox IE used in pc. But UC browser on my windows mobile shows the file extension as unknown(eg: if file is video1.mp4 , my downloaded file is video1.unknown).
Any help welcome.

// Add bellow code for mime type
$temp = explode(".",$myfile);
$ext = strtolower(end($temp));
$mime_types = array(

// video
'3gp' => 'video/3gpp',
'3g2' => 'video/3g2',
'avi' => 'video/avi',
'mp4' => 'video/mp4',
'asf' => 'video/asf',
'mov' => 'video/quicktime',
if (array_key_exists($ext, $mime_types)){
$fname=str_replace(" ","_",$result->TITLE);
//header("Cache-Control: public, must-revalidate");
header("Pragma: public");

header("Content-Type: ".$mm_type);

header('Content-Disposition: attachment; filename='.$fname);
header('Content-Length: '.filesize($myfile));
header("Content-Transfer-Encoding: binary");
echo "unable to download";


Answer Source

Adding file extension with the filename solves the issue.