에서 데이터베이스에 업로드 된 파일 이름을 추가 내가 누군가의 blueimp 파일 업로드의 jQuery 플러그인 약간의 경험이있다 바라고 어떻게 데이터베이스에 업로드 된 파일 이름을 추가 https://github.com/blueimp/jQuery-File-Upload는 blueimp 파일 업로드의 jQuery 플러그인
를? 옵션 배열에
에서 데이터베이스에 업로드 된 파일 이름을 추가 내가 누군가의 blueimp 파일 업로드의 jQuery 플러그인 약간의 경험이있다 바라고 어떻게 데이터베이스에 업로드 된 파일 이름을 추가 https://github.com/blueimp/jQuery-File-Upload는 blueimp 파일 업로드의 jQuery 플러그인
를? 옵션 배열에
($this->options = array(
찾는다) 펑션 handle_file_upload 삽입 한 후이어서
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
$index = null, $content_range = null) {
$file = new stdClass();
$file->name = $this->get_file_name($name, $type, $index, $content_range);
$file->size = $this->fix_integer_overflow(intval($size));
$file->type = $type;</code></pre>
삽입 코드 후
//Start added coded
// prepare the image for insertion
$data = addslashes (file_get_contents($uploaded_file));
// get the image info..
$size = getimagesize($uploaded_file);
$file->upload_to_db = $this->add_img($data, $size, $name);
//end added code
및
다음을'database' => 'database_name',
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
삽입 databa에 실제로 이미지를 업로드하는 코드 se. 당신이이 add_img($size,$name)
에 add_img($data,$size,$name)
을 변경하고 단지 $ 데이터 변수를 전달하지 않는 원하지 않는 경우
function query($query) {
$database = $this->options['database'];
$host = $this->options['host'];
$username = $this->options['username'];
$password = $this->options['password'];
$link = mysql_connect($host,$username,$password);
if (!$link) {
die(mysql_error());
}
$db_selected = mysql_select_db($database);
if (!$db_selected) {
die(mysql_error());
}
$result = mysql_query($query);
mysql_close($link);
return $result;
}
function add_img($data,$size,$name)
{
$add_to_db = $this->query("INSERT INTO your_database_name
(image_type ,image, image_size, file_name)
VALUES
('{$size['mime']}', '{$data}', '{$size[3]}', '{$name}')") or die(mysql_error());
return $add_to_db;
}
이
은 데이터베이스의 실제 이미지를 저장합니다.$data
변수는 중간 또는 긴 blob로 저장해야합니다.
파일 업로드를 디렉토리에 주석으로 처리하여 이미지를 디렉토리에 업로드하지 않으면 오류가 발생하지 않도록 할 수 있습니다. 이것은 protected function handle_file_upload
//comment out file upload stuff since storing in database
/*
if ($this->validate($uploaded_file, $file, $error, $index)) {
$this->handle_form_data($file, $index);
$upload_dir = $this->get_upload_path();
if (!is_dir($upload_dir)) {
mkdir($upload_dir, $this->options['mkdir_mode'], true);
}
$file_path = $this->get_upload_path($file->name);
$append_file = $content_range && is_file($file_path) &&
$file->size > $this->get_file_size($file_path);
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads)
if ($append_file) {
file_put_contents(
$file_path,
fopen($uploaded_file, 'r'),
FILE_APPEND
);
} else {
move_uploaded_file($uploaded_file, $file_path);
}
} else {
// Non-multipart uploads (PUT method support)
file_put_contents(
$file_path,
fopen('php://input', 'r'),
$append_file ? FILE_APPEND : 0
);
}
$file_size = $this->get_file_size($file_path, $append_file);
if ($file_size === $file->size) {
$file->url = $this->get_download_url($file->name);
list($img_width, $img_height) = @getimagesize($file_path);
if (is_int($img_width) &&
preg_match($this->options['inline_file_types'], $file->name)) {
$this->handle_image_file($file_path, $file);
}
} else {
$file->size = $file_size;
if (!$content_range && $this->options['discard_aborted_uploads']) {
unlink($file_path);
$file->error = 'abort';
}
}
$this->set_additional_file_properties($file);
}
*/
에 있습니다. 서버 측에서 PHP를 사용합니까? –