PHP - 无法打开上传图像的流错误

标签 php mysql

HTML 代码:

<input type="file" name="files[]" multiple="multiple" id="photo" >

PHP 代码:

$query1="insert into imgtab values('".$ka."','".addslashes(file_get_contents($_FILES['files']['name'][$i]))."')";

错误:

Warning: file_get_contents(Screenshot (5).png): failed to open stream: No such file or directory in C:\xampp\htdocs\q.php on line 16

如何解决这个错误?

最佳答案

尝试使用 file_get_contents($_FILES['files']['tmp_name'][$i]) 代替,因为 ['name'] 是对上传的文件名,而不是文件位置。 It is also bad practice to store files in the database 。所以你最好使用move_uploaded_file(...)然后将该位置存储到数据库而不是实际的文件内容。

关于PHP - 无法打开上传图像的流错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33591041/

相关文章:

javascript - 如何将变量和数据从 PHP 传递到 JavaScript?

php - Phonegap,Mysql,ajax//无插入

php - 如何从数组推送中编码json?

MySQL 工作台。错误 1452 : Cannot add or update a child row: a foreign key constraint fails. 操作失败

php - 向时间戳添加值

php - MySQL问题: The right way to calculate some data from different tables

javascript - jQuery 函数 $.post 和 .remove

php - 根据目录结构自动加载命名空间

php - 将user_id添加到Session mysql中

java - 当数据来自 mySQL 时,在 java 的 Spinner 中删除重复项