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;
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False