在Laravel 5.1中上传图像的功能是什么 [英] What is the function to upload images in Laravel 5.1

查看:78
本文介绍了在Laravel 5.1中上传图像的功能是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像上传到数据库中,也要上传到特定的文件夹中.我研究了许多教程,但没有找到具体答案.所以请帮帮我.我尝试了$request->file('image')->move($destinationPath, $fileName);,但是它不起作用.

I want to upload an image in database and also into a specific folder. I studied many tutorials but I did not find specific answer. So please help me. I tried $request->file('image')->move($destinationPath, $fileName); but it doesn't work.

推荐答案

尝试一下:

Input::file('photo')->move($destinationPath, $fileName);

OR

Input::file('photo')->move($destinationPath);

在这里, 照片将是您要保存的图像.

Here, photo will be your image, you want to save.

$ destinationPath :您要存储上传的图片的位置

$destinationPath: Where you want to store your uploaded image

$ fileName :您的图片文件名(可选)

$fileName: Your image filename (optional)

您用来上传文件的表格应采用以下格式:

Your Form, through which you are uploading the file, should be in this format:

{!! Form::open(array('name'=>'create', 'method'=>'POST', 'files'=>true, 'url'=>'some/path')) !!}

{!! Form::close() !!}

看,如果有帮助. (有关更多信息,请参见此处)

See, if that helps. (For More info see here)

这篇关于在Laravel 5.1中上传图像的功能是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆