Php file download $ filefolderfilename. ext; functionforce_download ($ file ){??? Truncation file extension ??? $ Extexplode (., $ file );??? Switch ($ ext [sizeof ($ ext)-1]) {??? Download a casej PHP file
// $ File = "/folder/filename. ext ";
Function force_download ($ file ){
??? // Intercept the file extension
??? $ Ext = explode (".", $ file );
??? Switch ($ ext [sizeof ($ ext)-1]) {
??????? Case 'jar': $ mime = "application/java-archive"; break;
??????? Case 'Zip': $ mime = "application/zip"; break;
??????? Case 'jpeg ': $ mime = "image/jpeg"; break;
??????? Case 'jpg ': $ mime = "image/jpg"; break;
??????? Case 'jad': $ mime = "text/vnd. sun. j2-app-descriptor"; break;
??????? Case "gif": $ mime = "image/gif"; break;
??????? Case "png": $ mime = "image/png"; break;
??????? Case "pdf": $ mime = "application/pdf"; break;
??????? Case "txt": $ mime = "text/plain"; break;
??????? Case "doc": $ mime = "application/msword"; break;
??????? Case "ppt": $ mime = "application/vnd. ms-powerpoint"; break;
??????? Case "wbmp": $ mime = "image/vnd. wap. wbmp"; break;
??????? Case "wmlc": $ mime = "application/vnd. wap. wmlc"; break;
??????? Case "mp4s": $ mime = "application/mp4"; break;
??????? Case "ogg": $ mime = "application/ogg"; break;
??????? Case "pls": $ mime = "application/pls + xml"; break;
??????? Case "asf": $ mime = "application/vnd. ms-asf"; break;
??????? Case "swf": $ mime = "application/x-shockwave-flash"; break;
??????? Case "mp4": $ mime = "video/mp4"; break;
??????? Case "m4a": $ mime = "audio/mp4"; break;
??????? Case "m4p": $ mime = "audio/mp4"; break;
??????? Case "mp4a": $ mime = "audio/mp4"; break;
??????? Case "mp3": $ mime = "audio/mpeg"; break;
??????? Case "m3a": $ mime = "audio/mpeg"; break;
??????? Case "m2a": $ mime = "audio/mpeg"; break;
??????? Case "mp2a": $ mime = "audio/mpeg"; break;
??????? Case "mp2": $ mime = "audio/mpeg"; break;
??????? Case "mpga": $ mime = "audio/mpeg"; break;
??????? Case "wav": $ mime = "audio/wav"; break;
??????? Case "m3u": $ mime = "audio/x-mpegurl"; break;
??????? Case "bmp": $ mime = "image/bmp"; break;
??????? Case "ico": $ mime = "image/x-icon"; break;
??????? Case "3gp": $ mime = "video/3gpp"; break;
??????? Case "3g2": $ mime = "video/Audio pp2"; break;
??????? Case "mp4v": $ mime = "video/mp4"; break;
??????? Case "mpg4": $ mime = "video/mp4"; break;
??????? Case "m2v": $ mime = "video/mpeg"; break;
??????? Case "m1v": $ mime = "video/mpeg"; break;
??????? Case "mpe": $ mime = "video/mpeg"; break;
??????? Case "mpeg": $ mime = "video/mpeg"; break;
??????? Case "mpg": $ mime = "video/mpeg"; break;
??????? Case "mov": $ mime = "video/quicktime"; break;
??????? Case "qt": $ mime = "video/quicktime"; break;
??????? Case "avi": $ mime = "video/x-msvideo"; break;
??????? Case "midi": $ mime = "audio/midi"; break;
??????? Case "mid": $ mime = "audio/mid"; break;
??????? Case "amr": $ mime = "audio/amr"; break;
??????? Default: $ mime = "application/force-download ";
??? }
??? Header ('content-Description: File Transfer ');
??? Header ('content-Type: '. $ mime );
??? Header ('content-Disposition: attachment; filename = '. basename ($ file ));
??? Header ('content-Transfer-Encoding: binary ');
??? Header ('expires: 0 ');
??? Header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0 ');
??? Header ('pragma: public ');
??? Header ('content-Length: '. filesize ($ file ));
??? Ob_clean ();
??? Flush ();
??? Readfile ($ file );
}?