图片网址无效,添加了网站网址(Image URL not working, has site URL added)
我有一个PHP脚本从目录中获取最新的图像。 该脚本似乎工作并返回以下内容:
<img src="webcam3/FI9804W_00626E4E4229/snap/Schedule_20140923-105158.jpg" alt="Webbkamera 3">
base_url看起来像这样:
$base_url = 'webcam3/FI9804W_00626E4E4229/snap';
但是,链接附加了站点URL,因此链接读取
http://www.hlmfk.se/webbkameror/kameratest/webcam3/FI9804W_00626E4E4229/snap/Schedule_20140923-105158.jpg
...当地址应该是www.hlmfk.se/webcam3 / ...如何防止将网站URL添加到图像链接? 谢谢!
脚本看起来像这样,并在主题functions.php中编写:
$dir = 'snap'; $base_url = 'webcam3/FI9804W_00626E4E4229/snap'; $newest_mtime = 0; $show_file = 'BROKEN'; if ($handle = opendir($base_url)) { while (false !== ($file = readdir($handle))) { if (($file != '.') && ($file != '..') && ($file != '.htaccess')) { $mtime = filemtime("$base_url/$file"); if ($mtime > $newest_mtime) { $newest_mtime = $mtime; $show_file = "$base_url/$file"; } } } }
I have a PHP script that fetches the latest image from a directory. The script seems to work and returns the following:
<img src="webcam3/FI9804W_00626E4E4229/snap/Schedule_20140923-105158.jpg" alt="Webbkamera 3">
The base_url looks like this:
$base_url = 'webcam3/FI9804W_00626E4E4229/snap';
However the link has the site URL appended to it, so the link reads
http://www.hlmfk.se/webbkameror/kameratest/webcam3/FI9804W_00626E4E4229/snap/Schedule_20140923-105158.jpg
...when the address should be www.hlmfk.se/webcam3/... How do I prevent the site URL being added to the image link? Thanks!
The script looks like this and is written in the theme functions.php:
$dir = 'snap'; $base_url = 'webcam3/FI9804W_00626E4E4229/snap'; $newest_mtime = 0; $show_file = 'BROKEN'; if ($handle = opendir($base_url)) { while (false !== ($file = readdir($handle))) { if (($file != '.') && ($file != '..') && ($file != '.htaccess')) { $mtime = filemtime("$base_url/$file"); if ($mtime > $newest_mtime) { $newest_mtime = $mtime; $show_file = "$base_url/$file"; } } } }
原文:https://stackoverflow.com/questions/25991211
更新时间:2024-03-11 07:03
最满意答案
相关问答
更多-
CSS Bootstrap下拉菜单(CSS Bootstrap Dropdown Menu)[2022-05-06]
你错放了CSS课程 应该只有一个.dropdown-menu,它包含所有.dropdown-menu-item元素Bootstrap Menu Ex。 belowe