【问题标题】:Laravel File Upload different versions and formats of a fileLaravel File 上传文件的不同版本和格式
【发布时间】:2019-01-30 06:59:03
【问题描述】:
让我知道一个样本。如何将上传的文件存储到数据库中;拉拉维尔
前任。
在系统中,如果上传一个doc文件,它会自动转换为PDF。(通过云转换API)。我如何将这两个文件保存在数据库中。
---------------------------------------------------
|id|proposal_id|version_id|Status|fileName|filetype|
---------------------------------------------------
【问题讨论】:
标签:
php
mysql
database
laravel
laravel-5
【解决方案1】:
最好将文件上传到公用文件夹内的文件夹中,并将链接文件夹保存在数据库中
你可以使用这样的代码:
if ($request->hasFile('image')) {
$file = array('image' => Input::file('image'));
$destinationPath = 'image/'; // upload path
$extension = Input::file('image')->getClientOriginalExtension();
$logofileName = rand(11111,99999).'.'.$extension; // renaming image
Input::file('image')->move($destinationPath, $logofileName);
}