Php 在laravel4中显示图像的问题
我使用Php 在laravel4中显示图像的问题,php,laravel-4,Php,Laravel 4,我使用laravel4中的InterventionPHP图像处理和操作库上传了一幅图像。通过使用这个库,我正确地上传了图像,但我面临的问题是,当我试图从数据库中显示这些图像时,它显示有一个无效的url。但是,url是有效的,我认为这是关于权限的问题 我发布以下权限,这是默认情况下给一个上传文件夹,也允许用户访问它是www数据 我的代码 @section('main') @extends('layouts/user') <h1>All Users</h1> <p&g
laravel4
中的Intervention
PHP图像处理和操作库上传了一幅图像。通过使用这个库,我正确地上传了图像,但我面临的问题是,当我试图从数据库中显示这些图像时,它显示有一个无效的url。但是,url是有效的,我认为这是关于权限的问题
我发布以下权限,这是默认情况下给一个上传文件夹,也允许用户访问它是www数据
我的代码
@section('main')
@extends('layouts/user')
<h1>All Users</h1>
<p>{{ link_to_route('users.create', 'Add new user') }}</p>
@if ($users->count())
<table class="table table-striped">
<thead>
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>Email</th>
<th>Address</th>
<th>Image</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->firstName }}</td>
<td>{{ $user->lastName }}</td>
<td>{{ $user->emailId }}</td>
<td>{{ $user->address }}</td>
<td>{{ HTML::image('uploadImg/B05BgJ_school-uniform.jpg') }}</td>
</td>
<td>{{ link_to_route('users.edit', 'Edit',
array($user->id), array('class' => 'btn btn-info')) }}</td>
<td>
{{ Form::open(array('method'
=> 'DELETE', 'route' => array('users.destroy', $user->id))) }}
{{ Form::submit('Delete', array('class'
=> 'btn btn-danger')) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="pagination"><?php echo $users->links(); ?></div>
@else
There are no users
@endif
@stop
@节('main')
@扩展('布局/用户')
所有用户
{{link_to_route('users.create','addnewuser')}
@如果($users->count())
名字
姓氏
电子邮件
地址
形象
行动
@foreach($users作为$user)
{{$user->firstName}
{{$user->lastName}
{{$user->emailId}
{{$user->address}
{{HTML::image('uploadImg/B05BgJ_school-uniform.jpg')}
{{link_to_route('users.edit','edit',',
数组($user->id),数组('class'=>'btn btn info'))}
{{Form::open(数组('method'
=>'DELETE','route'=>array('users.destroy',$user->id))}
{{Form::submit('Delete',array('class'
=>'btn btn danger'))}
{{Form::close()}}
@endforeach
@否则
没有用户
@恩迪夫
@停止
问题可能是图像的路径。
laravel应用程序的根目录是app/directory
尝试计算绝对路径:
HTML::image('/var/www/testLara/uploadImg/B05BgJ_school-uniform.jpg')
您应该将图像存储在
/public
目录的某个子目录中 问题可能是图像的路径。
laravel应用程序的根目录是app/directory
尝试计算绝对路径:
HTML::image('/var/www/testLara/uploadImg/B05BgJ_school-uniform.jpg')
您应该将图像存储在
/public
目录的某个子目录中 您创建/上传的任何图像都需要转到public/(或任何您的公用文件夹)之后,否则它将不会呈现为有效的url,因为请求将始终指向public folder/image folder/image.jpg或其他路径,并且根据图像中的文件夹结构,无法访问图像文件夹
在本例中,您创建了一个与app directory处于同一级别的文件夹uploadimg,而它应该位于public/uploadimg
我注意到的另一件事是,您要求从
{{ HTML::image('uploadImg/B05BgJ_school-uniform.jpg') }}
而它应该是从
{{ HTML::image('uploadimg/B05BgJ_school-uniform.jpg') }}
(假设图像名称和路径正确,如果uploadimg文件夹位于public/folder中,则此操作有效)您创建/上载的任何图像都需要位于public/(或任何您的公用文件夹)之后,否则它将无法呈现为有效的url,由于请求总是指向公用文件夹/image folder/image.jpg或其他内容的路径,并且根据图像中的文件夹结构,图像文件夹无法访问 在本例中,您创建了一个与app directory处于同一级别的文件夹uploadimg,而它应该位于public/uploadimg 我注意到的另一件事是,您要求从
{{ HTML::image('uploadImg/B05BgJ_school-uniform.jpg') }}
而它应该是从
{{ HTML::image('uploadimg/B05BgJ_school-uniform.jpg') }}
(假设图像名称和路径正确,如果uploadimg文件夹位于public/folder中,则此操作有效)
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
选项-多视图
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写规则^(+)/$http://%{http_HOST}/$1[R=301,L]
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
选项-多视图
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写规则^(+)/$http://%{http_HOST}/$1[R=301,L]
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
{{HTML::image('uploadImg/B05BgJ_school-uniform.jpg')}
的输出是什么