文件存储在mysql数据库中


file store in mysql database

我正在尝试将pdf文件存储在mysql数据库中。但是我犯了一些错误。

这是我的html--

<input type="file" class="form-control" id="content" name="content" accept=".pdf">

这是我的PHP代码——

$contents = file_get_contents($_FILES['content']);

但我总是收到这个错误---

注意:未定义的索引:$contents中的内容=file_get_contents($_FILES[内容])

警告:file_get_contents():$contents中的文件名不能为空=file_get_contents($_FILES[内容])

我做错了什么?我该怎么解决这个问题。

确保表单具有enctype属性,并且其值为multipart/form-data。如果没有它,您将得到空的$_FILE变量。

要阅读有关enctype的更多信息,请参阅http://www.w3schools.com/tags/att_form_enctype.asp