Php Laravel 4将图像上载到服务器
我正试图上传图像到laravel,我遇到了一些问题:S 我的看法是:Php Laravel 4将图像上载到服务器,php,image,laravel,Php,Image,Laravel,我正试图上传图像到laravel,我遇到了一些问题:S 我的看法是: <form role="form" method="post" action="{{url('admin/test')}}" id="formm" > <input type="file" placeholder="browse" id="imagen_item" name="imagen_item" accept="image/*"/> <input type=
<form role="form" method="post" action="{{url('admin/test')}}" id="formm" >
<input type="file" placeholder="browse" id="imagen_item" name="imagen_item" accept="image/*"/>
<input type="submit" style="font-size: 20px" class="btn btn-primary" value="Guardar">
</form>
我的控制器
public function test()
{
$file = Input::file('imagen_item');
var_dump($file);
$destinationPath = 'uploads/';
if(is_object($file))
{
$filename = $file->getClientOriginalName();
$upload_success = Input::file('imagen')->move($destinationPath, $filename);
if( $upload_success ) {
echo 'save this url: '.$filename." in the DB";
}
}
}
以及我在提交表格后得到的信息:
null
A
A.A
很明显,问题在于我没有从输入表单中读取图像。。但是为什么呢??我有相同的名字。。。谢谢大家! 解决了!
我将表单标记更改为:
{{ Form::open(array('url' => 'admin/rnew_item', 'files' => true,'id'=>'formm')) }}
以及ofc的:
{{ Form::close() }}
{{ Form::close() }}