如何通过php从网络路径加载图像 [英] How to load image from network path via php

查看:56
本文介绍了如何通过php从网络路径加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将网络路径中的图像加载到我的php文件中.这是我的代码:

I am trying to load an image from a network path into my php file. Here is my code:

<?php
    $image_src="//SERVER/2 MESHES/80 - RailClone Lib/Geländer/thumbnails/Geländer 2.jpg";
    echo '<img src='.$image_src.' alt="No Image">';
?>

图像未加载---我一直都没有图像.要访问网络服务器上的文件,我该怎么做?我正在使用Firefox.感谢您的帮助!

The image is not loaded --- I alwas see No Image. What do I have to do to access the file on the network server? I am using firefox. Thanks for helping!

添加:我将图片来源更改为

Addition: I changed the image Source to

$image_src="file://S:/2 MESHES/80 - RailClone Lib/Geländer/thumbnails/Geländer 2.jpg";

echo "<img src='".$image_src."' alt='No Image'>";

现在,我可以将代码从源代码中复制出来,并在浏览器中打开,但是php文件不会加载该文件.

Now I can copy the code out of the sourcecode and it opens in the browser, but the php file does not load the file.

生成的源代码如下:

<img src='file://S:/2 MESHES/80 - RailClone Lib/Geländer/thumbnails/Geländer 2.jpg' alt='No Image'> 

推荐答案

使用 $ _ SERVER ["DOCUMENT_ROOT"] 获取服务器的正确路径以获取映像.

USE $_SERVER["DOCUMENT_ROOT"] to get the correct path of the server to get the Image.

更正

echo< img src =".$ image_src."alt ='No Image'>";

<?php

 $image_src="//SERVER/2 MESHES/80 - RailClone Lib/Geländer/thumbnails/Geländer 2.jpg";
    echo "<img src=".$image_src." alt='No Image'>";

?>

这篇关于如何通过php从网络路径加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆