jquery-file-upload 的php mysql插入有關問題

來源:互聯網
上載者:User
jquery-file-upload 的php mysql插入問題
最近用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,
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.