无法使用glob PHP访问带符号链接的文件

时间:2016-06-22 21:41:30

标签: php

我为目录/home/pi/app创建了符号链接到/var/www/html我可以轻松地在该文件夹中显示图像

  echo '<img src="/images/test.jpg"/><br />';

但是我无法使用glob函数显示该文件夹中的图像列表。

$images = glob("/images/*.jpg");

foreach($images as $image) {
    echo '<img src="'.$image.'" /><br />';
 }

有什么方法可以使用glob显示这些图像?如果我不能使用&#34; glob&#34;我可以使用任何功能吗?

3 个答案:

答案 0 :(得分:1)

我意识到这是一个老问题,但是我遇到了类似的问题,就我而言,我不得不在我的Apache虚拟机的import cv2 import numpy as np def convolution_filter(gray_img, kernel): # temporary operation # gray_img = cv2.resize(gray_img, (10, 10)) kernel_size = len(kernel) row = gray_img.shape[0] - kernel_size + 1 col = gray_img.shape[1] - kernel_size + 1 result = np.zeros(shape=(row, col)) for i in range(row): for j in range(col): current = gray_img[i:i+kernel_size, j:j+kernel_size] multiplication = np.abs(sum(sum(current * kernel))) result[i, j] = multiplication return result img = cv2.imread("input.jpeg") gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) k = [[0, -1, 0], [-1, 4, -1], [0, -1, 0]] filtered = convolution_filter(gray, k) cv2.imwrite("filtered.jpg", filtered) 值中添加符号链接绝对路径。

答案 1 :(得分:0)

setTimeout适用于文件系统级别。您提供的网络空间网址在您的服务器上不存在。

e.g。你做的相当于

    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    76  Yourtime
    Error   12  Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    10  Yourtime
    Error   41  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    67  Yourtime
    Error   19  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    34  Yourtime
    Error   13  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    24  Yourtime
    Error   26  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    44  Yourtime
    Error   32  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    53  Yourtime
    Error   46  Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    81  Yourtime
    Error   16  Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.DrawerArrowToggle'.   C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    29  Yourtime
    Error   37  Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.DrawerArrowToggle'.   C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    61  Yourtime
    Error   9   Error retrieving parent for item: No resource found that matches the given name 'Widget.Design.TabLayout'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    5   Yourtime
    C:\Users\Ahmed\Desktop\App6\App6\obj\Debug\res\drawable-mdpi\prof.png   Yourtime
    Error   17  No resource found that matches the given name: attr 'color'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    30  Yourtime
    Error   38  No resource found that matches the given name: attr 'color'.    C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    64  Yourtime
    Error   20  No resource found that matches the given name: attr 'colorAccent'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    39  Yourtime
    Error   27  No resource found that matches the given name: attr 'colorAccent'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    50  Yourtime
    Error   33  No resource found that matches the given name: attr 'colorAccent'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    58  Yourtime
    Error   42  No resource found that matches the given name: attr 'colorAccent'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    71  Yourtime
    Error   47  No resource found that matches the given name: attr 'colorAccent'.  C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    82  Yourtime
    Error   14  No resource found that matches the given name: attr 'colorPrimary'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    25  Yourtime
    Error   21  No resource found that matches the given name: attr 'colorPrimary'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    37  Yourtime
    Error   28  No resource found that matches the given name: attr 'colorPrimary'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    48  Yourtime
    Error   34  No resource found that matches the given name: attr 'colorPrimary'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    56  Yourtime
    Error   43  No resource found that matches the given name: attr 'colorPrimary'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    69  Yourtime
    Error   22  No resource found that matches the given name: attr 'colorPrimaryDark'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    38  Yourtime
    Error   29  No resource found that matches the given name: attr 'colorPrimaryDark'. C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    49  Yourtime
'tabTextAppearance'.        C:\Users\Ahmed\Desktop\App6\App6\Resources\values\Styles.xml    47  Yourtime
    Error   25  No resource found that matches the given name: attr 'windowNoTitle'.

但您提供的路径仅作为

存在
glob()

所以..

 glob('c:\images\*')

查看文件系统的顶级,而不是网站文档根目录的顶级。如果您只有 glob('c:\inetpub\wwwroot\example.com\images\*'); ,那么glob将查找您的脚本正在执行的任何目录的子目录。

答案 2 :(得分:0)

URL中的路径名相对于服务器的文档根目录进行解释。您可以使用$_SERVER['DOCUMENT_ROOT']在PHP中获取该目录。

$images = glob($_SERVER['DOCUMENT_ROOT'] . "/imags/*.jpg");
foreach ($images as $image) {
    echo '<img src="/images/'.basename($image).'" /><br />';
}