所以基本上https://github.com/blueimp/jQuery-File-Upload/wiki作为上传者,我正在使用其在服务器端移动的块功能。我在获取上传文件的最后一块时遇到了问题。
我想要做的是,一旦块到达最后一个块,或者上传者完成上传块,只保存到db
离。块大小= 10mb
if( isset($_SERVER['HTTP_CONTENT_RANGE']) )
{
$content_range = preg_split('/[^0-9]+/', $_SERVER['HTTP_CONTENT_RANGE']);
// if file is greater or equal to 10mb
if( $content_range[2] + 1 == $content_range[3] )
{
insert data to database here
}
// if file does not need to be chunked file is less than chunk size
else
{
also insert the data to database
}
}
答案 0 :(得分:0)
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$is_chunked_upload = !empty($_SERVER['HTTP_CONTENT_RANGE']);
if ($is_chunked_upload) {
$is_last_chunk = false;
// [HTTP_CONTENT_RANGE] => bytes 10000000-17679248/17679249 - last chunk looks like this
if (preg_match('|(\d+)/(\d+)|', $_SERVER['HTTP_CONTENT_RANGE'], $range)) {
if ($range[1] == $range[2] - 1) {
$is_last_chunk = true;
}
}
}
}