jquery-file-upload的phpmysql插入有关问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery-file-upload的phpmysql插入有关问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2509字,纯文字阅读大概需要4分钟。
内容图文
![jquery-file-upload的phpmysql插入有关问题](/upload/InfoBanner/zyjiaocheng/229/a31670ce817e447782d277b12112c29a.jpg)
最近用jquery-file-upload 来改善网站上传的体验
https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration
上传时按照他的参考文档,立马就完成了,一开始也按照他的sql 架构先试试
结果上传后,也能成功插入,json传回页面一切正常!
但问题来了,他的sql 架构...有个叫url
但作者好像在PHP的SQL中没有处理
那我就改改吧,....
先新增了一些基本配置
$dir = $_COOKIE["uid"].'/'.date("Y").'/'.date("m").'/'.date("d").'/';
$dirUP = "../../../att/".$dir;
$dirLink = $dir;
$options=array(
'upload_dir' => $dirUP,
'upload_url' => $dirLink,
'delete_type' => 'POST',
'db_host' => 'localhost',
'db_user' => 'root',
'db_pass' => '*****',
'db_name' => '*****',
'db_table' => 'files'
);
应该就是这段了....
我尝试多次,加入url字段都不成功 [原本的文档代码]
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
$index = null, $content_range = null) {
$file = parent::handle_file_upload(
$uploaded_file, $name, $size, $type, $error, $index, $content_range
);
if (empty($file->error)) {
$sql = 'INSERT INTO `'.$this->options['db_table']
.'` (`name`, `size`, `type`, `title`, `description`)'
.' VALUES (?, ?, ?, ? , ?)';
$query = $this->db->prepare($sql);
$query->bind_param(
'sisss',
$file->name,
$file->size,
$file->type,
$file->title,
$file->description
);
$query->execute();
$file->id = $this->db->insert_id;
}
return $file;
}
都给我显示:
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in
这是什么意思,说我的数量有问题? 是指我加少了吗?
我已经改成...这样,5处的type字段也都加了url也说是数量问题?
protected function handle_file_upload($uploaded_file, $name, $size, $type,$url, $error,
$index = null, $content_range = null) {
$file = parent::handle_file_upload(
$uploaded_file, $name, $size, $type,$url, $error, $index, $content_range
);
if (empty($file->error)) {
$sql = 'INSERT INTO `'.$this->options['db_table']
.'` (`name`, `size`, `type`, `url`, `title`, `description`)'
.' VALUES (?, ?, ?, ?,? , ?)';
$query = $this->db->prepare($sql);
$query->bind_param(
'sisss',
$file->name,
$file->size,
$file->type,
内容总结
以上是互联网集市为您收集整理的jquery-file-upload的phpmysql插入有关问题全部内容,希望文章能够帮你解决jquery-file-upload的phpmysql插入有关问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】