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/