我在Laravel 4中有一个通过POST方法发送文本文件的表单.然而,在Controller中,我无法弄清楚如何获取其内容以便将其放入DB中的BLOB字段.
Laravel的文档和我在网上找到的所有帖子总是展示如何使用该->move()方法将内容保存到文件中.
这是我在Controller中的代码:
$book = Books::find($id);
$file = Input::file('summary'); // get the file user sent via POST
$book->SummaryText = $file->getContent(); <---- this is the method I am searching for...
$book->save(); // save the summary text into the DB
Run Code Online (Sandbox Code Playgroud)
(SummaryText是我的数据库表上的MEDIUMTEXT).
那么,如何在Laravel 4.1中获取文件内容,而不必将其保存到文件中?那可能吗?
我正在使用Laravel 5.2,我想创建一个可以上传pdf文件的表单.我想将该文件添加到"public"文件夹中的"files"文件夹中.
这是我的看法:
<div class="form-group">
<label for="upload_file" class="control-label col-sm-3">Upload File</label>
<div class="col-sm-9">
<input class="form-control" type="file" name="upload_file" id="upload_file">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
接下来我该怎么办?我应该在控制器和路线中添加什么?