Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output an Image in PHP

Tags:

php

image

I have an image $file ( eg ../image.jpg )

which has a mime type $type

How can I output it to the browser?

like image 684
steven Avatar asked Dec 05 '09 10:12

steven


People also ask

How can we store image in variable in PHP?

Store the image in a variable such that, Echo the image from the variable without changing headers. You can do this in two ways. In way one, you serialize the image in a string, and save the string in the session.

What is Imagepng?

PNG is short for Portable Network Graphic, a type of raster image file. It's particularly popular file type with web designers because it can handle graphics with transparent or semi-transparent backgrounds.

What is purpose of Image_create () method in python?

The imagecreate() function is used to create a new image. It is preferred to use imagecreatetruecolor() to create an image instead of imagecreate().


1 Answers

$file = '../image.jpg'; $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($file)); readfile($file); 
like image 73
Emre Yazici Avatar answered Sep 18 '22 17:09

Emre Yazici