Jump to content

mime_content_type


tarun

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.