Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to give output an image using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 130
    Comment on it

    Hello Reader's if you want to give output as an image then you can use the code below:-

    You can use finfo (PHP 5.3+) to get the right MIME type.

    $filePath = 'yourfile.ext';
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $contentType = finfo_file($finfo, $filePath);
    finfo_close($finfo);
    
    header('Content-Type: ' . $contentType);
    readfile($filePath);
    

    Note : You don't have select Content-Length, Appache will take care of it

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: