I am using a jquery-file-upload plugin with its own server-side file to run with. like here on github https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration
At first,everything went good,but after I added 2 other value to the database and to the PHP server-end files, it always return an error of 'SyntaxError: Unexpected token <'
here's my modifications of the codes:
protected function handle_form_data($file, $index) {
$untitle = @$_REQUEST['title'][$index];
$potitle = urlencode($untitle);
$file->title = $potitle;
$file->description = @$_REQUEST['description'][$index];
$file->cat =@ $_REQUEST['cat'][$index];
}
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`, `cat`, `url`, `title`, `description`)'
.' VALUES (?, ?, ?, ?, ?, ?, ?)';
$query = $this->db->prepare($sql);
$url = get_download_url($name, $version = null);
$file->url = $url;
$query->bind_param(
'sisss',
$file->name,
$file->size,
$file->type,
$file->cat,
$file->url,
$file->title,
$file->description
);
$query->execute();
$file->id = $this->db->insert_id;
}
return $file;
}