dongyi1777 2014-04-03 14:58
浏览 355

使用URL从URL显示图像

Well, I've been on nearly all the posts regarding this issue. I still can't seem to get this working.

I'm basically following this:

http://www.w3schools.com/php/php_file_upload.asp

I've got it all working and even managed to get the uploaded picture to display on a php page.

The problem is really, is that I'd like it so that it wouldn't just display the last picture you uploaded, but instead any picture that is in the "uploads" folder.

I'd like to do this in a separate php from the tutorial and the URL would look something like this:

http://myexample.com/display.php?pic=ImAPicture

This way, all the pictures in the uploads folder can be displayed as long as you have the name.

I've played about with it, but I can't seem to get it to work.

Please refer to the tutorial to know roughly how I'm working with it.


To Sharky, I am unable to reply. I tried your code but I got an error

Parse error: syntax error, unexpected '}' in /websites/123reg/LinuxPackage21/fl/an/de/flanderskiller.com/public_html/display.php on line 12

I deleted the }

and then I got a new error

Parse error: syntax error, unexpected T_IF in /websites/123reg/LinuxPackage21/fl/an/de/flanderskiller.com/public_html/display.php on line 14

Please help. Thank you!

  • 写回答

2条回答 默认 最新

  • doushi5024 2014-04-03 15:20
    关注

    You need to read your image and echo it with header Content-type: image/jpeg or image/png like this:

    <?php
        $image = file_get_contents("path/to/image.jpg");
        header("Content-type: image/jpeg");
        echo $image;
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用