Monday 15 June 2015

PHP 5.3 MIME type header not working for any video types -


I am writing a proxy script that accesses files outside the WWW Public directory. Everything works as expected, it successfully returns the audio, image, text, and flash MIME type files. However, I can not find any video MIME type to work in. Could get an error message in Firefox "The best I can tell an error message in Firefox" can not be corrupted because the file is corrupt. "

  need_once (dirname (dirname (dirname (__ FILE__). '/config.php'); require_login (); // To access global $ CFG files, the user is logged in If; (isset ($ _gET ['content'])) {// the content path $ swf_disallowed = array ('../', 'arc', '/ / /'); $ Swf_replace = array $ (Swf_content = str_replace ($ swf_disallowed, $ swf_replace, $ _GET ['content']);} and (die);} // Make sure to try in a server file Before all the conditions are met: // should be "". If within the last 4 checks (stropo ($ swf_content, '.') & Gt; strlen ($ swf_content) - 6) {$ swf_file_extention = Substr ($ swf_content, strrpos ($ swf_content, '.')); // MIME type $ swf_file = $ CFG- & gt; Get file extension to set up Duplicate. $ CFG-> swf_content_dir. $ Swf_content ; // Complete path to complete} other {dead;} ​​// Please note: extension = php_fileinfo.dll or extension = php_fileinfo.so // should be able to call the following class and function. // $ swf_finfo = new file (FILEINFO_MIME); // echo $ swf_finfo-> File ($ swf_file); // File must be done (file_exists ($ swf_file) & amp; is_readable ($ swf_file)) // Set MIME type TODO - Test these in Firefox, IE, Chrome, Safari, Opera and JW Player Switch ($ swf_file_extention) {// audio case '.aac': $ swf_mime = 'audio / mp4'; // Firefox works in brakes; Case '.f4a': $ swf_mime = 'Video / MP4'; // test breaks; Case '.m4a': $ swf_mime = 'video / mp4'; // test breaks; Case ' Mp3 ': $ swf_mime =' audio / mpeg '; // Firefox works in brakes; // Image case '.gif': $ swf_mime = 'image / gif'; // Firefox works in brakes; Case '.jpeg': $ swf_mime = 'image / jpeg'; // Firefox works in brakes; Case '.jpg': $ swf_mime = 'image / jpeg'; // Firefox works in brakes; Case ' PNG ': $ swf_mime =' image / png '; // Firefox works in brakes; // Text case '.smil': $ swf_mime = 'text / xml'; // Firefox works in brakes; Case '.xml': $ swf_mime = 'text / xml'; // Firefox works in brakes; // video case '.f4v': $ swf_mime = 'video / x-flv'; // file.php offers download breaks; Case '.flv': $ swf_mime = 'video / x-flv'; // file.php offers download breaks; Case '.m4v': $ swf_mime = 'video / x-m4v'; // file.php offers download breaks; Case '.mov': $ swf_mime = 'Video / MP4'; // file.php offers download breaks; Case '.mp4': $ swf_mime = 'video / mp3'; // Firefox does not work in brakes; // Flash case '.swf': $ swf_mime = 'application / x-shockwave-flash'; // Firefox works in brakes; Default: $ swf_mime = false; } // If any valid mime type exists, display the image // by sending the appropriate title and file streaming ($ swf_mime) {header ('content-type:'. $ Swf_mime); Header ('content-length:' .make file ($ swf_file)); $ File = @ fopen ($ swf_file, 'rb'); If ($ file) {fpassthru ($ file); Go out; }}} // There is no closing PHP tag!    

OK, I got a solution to my question, it seems that large files For fpassthru () call ob_end_clean () before it is required.

  // If there is a valid mime type, display an image by sending the appropriate headers and streaming the file ($ Swf_mime) {Header ('Content-Type:'. $ Swf_mime) ; Header ('content-length:' .make file ($ swf_file)); $ File = @ fopen ($ swf_file, 'rb'); If ($ file) {// Fatal error: 134217728 bytes allowed memory size expired (264744961 attempts to allocate bytes) // fpassthru handles video files badly! Readfile is the same! Ob_end_clean (); // Required or big files will not work as a foremost ($ file); Go out; }}    

No comments:

Post a Comment