duandianzhong8315 2011-10-20 22:25
浏览 59
已采纳

使用<img>标签调用另一个php文件

image.html - <img src="showImage.php?id=44"/> <-- this is the code I'm trying to make work.

showImage.php - <?php echo ("showImage.php called"); ?> <-- this is the php file I'm trying to call.

The problem is.. img tag is not calling 'showImage.php' to print out "showImage.php called.". Instead, it tries to display showImage.php file as an image :( ... and doesn't display what it's supposed to. Am I doing something wrong here?

*Note: id=44 will be used for something else... not a big concern here.

Thank you.

  • 写回答

3条回答 默认 最新

  • dselp3944 2011-10-20 22:28
    关注

    If you actually visit that page in the browser, I'm sure it will print out showImage.php called in the browser. However, you're specifying that the file should be an image in your HTML and the browser is trying to treat it as an image. When it gets a text/html file instead, the browser merely shows that the image was invalid, it does not print the text instead. Your showImage.php will need to actually output an image in order for the browser to render it inside your document. Otherwise, you'll have to visit the page manually to see any text it's outputting for debugging, etc.

    All in all, it is calling your file, the browser is just ignoring the result. It will never show text instead of an image, unless you specify an alt attribute.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况