如何从url中获取imageurl?这样就可以在页面中显示出我想要的图片了
所以我有这个页面 .html , .php ,无论如何,这是一个带有我的徽标、一些广告、菜单等的页面。 我希望此页面显示我想要的图像,假设我有 /images/image1.jpg 并且我想将其发送给某人,但我希望那个人在我的网站中看到它,所以我会这样 mypage.com/example.php(somecodehere?)/images/image1.jpg
它将打开 example.php (或 .html),其中 image1.jpg 显示我的代码所在位置(假设在中间)
任何简单的方法做这个吗?
谢谢
So I have this page .html , .php, whatever, It's a page with my logo, some ads, menus etc.
I want this page to show the image I want, Let's say I have /images/image1.jpg and I want to sent it to someone, but I want that person to see it in my website so I would so something like
mypage.com/example.php(somecodehere?)/images/image1.jpg
And it would open example.php (or .html) with image1.jpg displaying where I had my code (let's say in the middle)
Any simple way to do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么,据我了解,您的网站上托管了一张图片,您希望通过某种链接与人们分享?
如果是这样,最好的方法是通过 GET 变量。
例如,如果您有一个名为:holiday.jpg 的图像,则链接将为:
http: //domain.com/example.php?img=holiday.jpg
您将看到类似以下内容
:
因此,在您的网页 example.php(必须具有 .php 扩展名)中, GET 变量中的斜杠例如: /image/directory/holiday.jpg 。通过用 %2F 替换破折号来正确地转义它
So, from my understanding you have an images hosted on your website that you wish to share with people via a link of some sort?
If so, the best way to do this is would be via GET variables.
For example, if you had an image called : holiday.jpg, the link would be:
http://domain.com/example.php?img=holiday.jpg
Therefore within your web page example.php (must have the .php ext) you would have something along the lines of :
Note
Be careful not to have slashes in your GET variable eg: /image/directory/holiday.jpg . Properly escape this by replace dashes with %2F
您应该使用 $_GET 来获取图像:
请注意,这是一个危险的代码,您应该始终检查用户的输入。
You should use the $_GET to get the image:
Be aware that this is a dangerous code and you should always check the input from the user.
您需要使用 $_GET[] 来获取图像路径。假设您的链接是:
现在,您需要获取该 img 值:
现在您拥有要显示的图像:)
You need to use $_GET[] in order to get the image path. Lets say that your link is:
Now, you need to get that img value:
Now you have the image that you want to display :)