我在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中获取文件内容,而不必将其保存到文件中?那可能吗?
我正在使用PHP 5.3.10.这是代码:
<?php
$email = "test@example.c";
if (filter_var($email, FILTER_VALIDATE_EMAIL))
echo "Email: ".$email." correct";
else
echo "email not correct";
?>
Run Code Online (Sandbox Code Playgroud)
它返回:"Email: test@example.c正确.
我认为只有一个字符的顶级域名不正确(根据此列表,我不知道单字符长度的TLD :) http://data.iana.org/TLD/tlds-alpha-by-domain.txt.
那么,FILTER_VALIDATE_EMAIL过滤器是否正常工作?