试图显示特定磁盘的图像

时间:2016-07-11 18:16:25

标签: image laravel

尝试这样做......

我的控制器

public function read(){
     $directory = 'c:\Users\Developer\Pictures';
     $info = [];
     $files = \File::files($directory);
     //$files = Storage::files($directory);

     foreach ($files as $file) {
          $info[] = pathinfo($file);
     }
     //var_dump($info);
     return view('uncataloged.read', compact('info'));
  }

我的观点

  @foreach($info as $file)
    <img src="{{$file['dirname']}}{{ $file['basename'] }}" width="220px" height="220px" ><br>
  @endforeach

获取此错误(Google Chrome)不允许加载本地资源:

我的代码出了什么问题?或其某种安全政策...

Ps:抱歉我的英文不好:P

感谢。

编辑 dd($ info);

array:11 [▼
  0 => array:4 [▼
    "dirname" => "c:\Users\Developer\Pictures"
    "basename" => "PHP_Logo.png"
    "extension" => "png"
    "filename" => "PHP_Logo"
  ]
  1 => array:4 [▶]
  2 => array:4 [▶]
  3 => array:4 [▶]
  4 => array:4 [▶]
  5 => array:4 [▶]
  6 => array:4 [▶]
  7 => array:4 [▶]
  8 => array:4 [▶]
  9 => array:4 [▶]
  10 => array:4 [▶]
]

0 个答案:

没有答案