1

I have this image www.site.com/folder1/image1.jpg, what I want to do is to access my image from a variable, for example www.site.com/image.php?q=varForImage1, it needs to work with <img> tag.
Example:
<img scr="www.site.com/image.php?q=varForImage1">

Any help?

Thanks

4

2 回答 2

0
<?php
// define $image_path as required
$image_path;
header('Content-type:'.mime_content_type($image_path));
echo file_get_contents($image_path);
die();
于 2013-10-15T18:03:37.740 回答
0

像这样的东西:

<?php
$image = $_GET['q'];  
$file = fopen('/path/to/'.$image, 'rb');  
header("Content-Type: image/png");

好吧,你当然应该改进代码,它可能只是给你一个想法。

于 2013-10-15T18:06:16.700 回答