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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.