tarun Posted March 31, 2007 Share Posted March 31, 2007 Ive Created A Quick Example But Why Doesn't It Work The Output I Get When I Go To: test.php?file=example.jpg Is: The File Type : "text/plain" Is Not Supported <?php $file = $_GET["file"]; $filetype = mime_content_type('$file'); if ( $filetype == "image/jpeg" ) { echo '<IMG SRC="'.$file.'">'; } else { echo 'The File Type : "'.$filetype.'" Is Not Supported'; } ?> Why Is It Doing This Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/ Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 It Would Not Work at All Cause The MIME Type Is Image/jpeg So It should output the image (Binary) But Its outputting the HTML(Text) Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218587 Share on other sites More sharing options...
tarun Posted March 31, 2007 Author Share Posted March 31, 2007 I Dont Think I Quite Get What Your Saying Can You Please Explain That In More Detail And A Bit Simpler Please Thnx Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218588 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 Sorry I didn't looked at the first Line Try this one <?php $file = $_GET["file"]; $filetype = mime_content_type('$file'); if($filetype == "image/jpeg") { header("Content-Type: image/jpeg"); $img_hwnd = imagecreatefromjpeg($file); imagejpeg($img_hwnd); imagedestroy($img_hwnd); } else { header("Content-Type: text/plain"); echo 'The File Type : "'.$filetype.'" Is Not Supported'; } ?> Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218590 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 It may also happen ----------------- It is Trying to access the Image in that very folder in which the php script is but its not getting that file in that folder. Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218591 Share on other sites More sharing options...
tarun Posted March 31, 2007 Author Share Posted March 31, 2007 To Script Is Supposed To Be Accessing Remote Files On Different Servers eg http://img47.imageshack.us/img47/4897/igtaruntextjl8.jpg Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218592 Share on other sites More sharing options...
tarun Posted March 31, 2007 Author Share Posted March 31, 2007 And I Get Different Errors Each Time I Refresh The Page 1. Warning: mime_magic: broken symlink ($file) in /home/www/**********/test2.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home/www/**********/test2.php:3) in /home/www/**********/test2.php on line 13 The File Type : "" Is Not Supported 2. The File Type : "application/octet-stream" Is Not Supported 3. The File Type : "text/plain" Is Not Supported 4. Warning: mime_magic: invalid mode 026752314425. in /home/www/**********/test2.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home/www/**********/test2.php:3) in /home/www/**********/test2.php on line 13 The File Type : "" Is Not Supported 5. The File Type : "httpd/unix-directory" Is Not Supported Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218594 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 Try This <?php $file = $_GET["file"]; $filetype = mime_content_type('$file'); if($filetype == "image/jpeg") { header("Content-Type: image/jpeg"); $img_hwnd = imagecreatefromjpeg('http://img47.imageshack.us/img47/4897/'.$file); imagejpeg($img_hwnd); imagedestroy($img_hwnd); } else { header("Content-Type: text/plain"); echo 'The File Type : "'.$filetype.'" Is Not Supported'; } ?> And Use your_page.php?file=igtaruntextjl8.jpg Link to comment https://forums.phpfreaks.com/topic/45026-mime_content_type/#findComment-218595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.