php从url获取图像
我需要创建一个返回JPEG图像的php文件。 我写了这段代码,但不起作用:php从url获取图像,php,image,url,Php,Image,Url,我需要创建一个返回JPEG图像的php文件。 我写了这段代码,但不起作用: <?php header('Content-type: image/jpeg;'); $p = 'http://....file.jpeg'; $a = file_get_contents('$p'); echo $a; ?> 怎么了?我认为这太简单了删除单引号: <?php header('Content-type: image/jpeg;'); $p = 'http://....file.jp
<?php
header('Content-type: image/jpeg;');
$p = 'http://....file.jpeg';
$a = file_get_contents('$p');
echo $a;
?>
怎么了?我认为这太简单了删除单引号:
<?php
header('Content-type: image/jpeg;');
$p = 'http://....file.jpeg';
$a = file_get_contents($p);
echo $a;
?>
您只需使用
'>
如果这不是您想要的功能,请查看如何使用 还是不行。我必须设置任何存档权限吗?现在是755它工作得非常好。我刚查过。在你的情况下,一定是别的什么东西不起作用了。你把文件放在磁盘上了吗?然后不要将url放在
$p
中,而是放在本地路径中。(如果这是你正在做的)。如果我们不知道错误是什么,那么很难调试代码…文件被放入服务器。如何检索错误?文件内容的输出是什么?什么不起作用?
<?php
$src = 'file.jpeg';
?>
<img src='<?php echo $src ?>'>