简体   繁体   English

与HTML / PHP的显示图像瓦帕

[英]Display image wamp with html/php

I'm actually new in this so this may sound ridiculous, but I'm really having struggle at this.我实际上是这方面的新手,所以这听起来可能很荒谬,但我真的很挣扎。

I want to load an image from my wamp server in my PHP file, where should I put the image?我想从我的 wamp 服务器加载一个图像到我的 PHP 文件中,我应该把图像放在哪里? And how can I access to it?我怎样才能访问它?

I've tried我试过了

<img data-src="http://localhost:8000/images/logo.jpg" alt="Generic placeholder image">

and so on, but nothing is working, is there something I am missing?等等,但没有任何效果,我错过了什么吗?

On server and on local are the same thing you can use relative path.在服务器和本地是一样的,你可以使用相对路径。

Example例子

 -page.html
 -images
    - image.jpg

in your page.html在你的 page.html

<img src="./images/image.jpg">

如果文件路径没问题,那么这将显示您的图像 - 尝试在浏览器中打开文件http://localhost:8000/images/logo.jpg如果它有效那么文件应该显示使用 img src="http:// localhost:8000/images/logo.jpg" alt="通用占位符图像" 而不是 data-src

Consider the following ficticious folder structure - the dots here signify a level in the heirarchy ( ie: subfolders )考虑以下虚构的文件夹结构 - 此处的点表示层次结构中的一个级别(即:子文件夹)

.document root
    ..css
    ..images
        ...jpg
        ...gif
        ...bmp
    ..includes
    ..js
    ..pages
        ...admin
        ...user
        ...gallery
    ..etc etc

Root relative paths would be a path that is relative to the document root, such as:-根相对路径将是相对于文档根的路径,例如:-

/images or /css

A folder relative path, from with say the pages directory might be文件夹的相对路径,比如 pages 目录可能是

../images/jpg

The dots, in the above, mean to go up a level in the folder heirarchy上面的点表示在文件夹层次结构中上升一个级别

The easiest and generally more common path to use would be root relative and for you use you could simply use the following if you have uploaded the logo.jpg file to the images directory.最简单且通常更常用的路径是相对于 root 的路径,如果您已将 logo.jpg 文件上传到图像目录,则可以简单地使用以下内容。

<img src="/images/logo.jpg" alt="Generic placeholder image" />

It should be noted that in the original you had used a dataset attribute value rather than the required src value expected by images.应该注意的是,在原始版本中,您使用了dataset属性值,而不是图像所需的src值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM