如何在上传页面上添加进度条?
我将使用Wordpress模板来集成上传器。
这是我现在拥有的上传程序代码:
global $post;
/*Video Uploading*/
if ( isset($_FILES['upload_attachment']) ) {
$count = '0';
$files = $_FILES['upload_attachment'];
foreach ($files['name'] as $key => $value) {
if ($files['name'][$key]) {
$file = array(
'name' => $files['name'][$key],
'type' => $files['type'][$key],
'tmp_name' => $files['tmp_name'][$key],
'error' => $files['error'][$key],
'size' => $files['size'][$key]
);
$_FILES = array("upload_attachment" => $file);
foreach ($_FILES as $file => $array) {
$newupload = betube_insert_attachment($file,$post->ID);
$attachvideo = wp_get_attachment_url( $newupload);
add_post_meta($post_id, 'jtheme_video_file', $attachvideo);
add_post_meta($post_id, '_video_thumbnail', $newupload);
set_post_thumbnail( $post_id, $newupload );
$count++;
}
}
}
}
发布于 2017-12-14 11:42:36
要添加进度条,必须使用jquery/ajax上载文件。有一个默认的javascript事件监听器,称为“进度”,用于增加进度条。这里是一个完整的工作示例,但是要确保您在wordpress中工作,这样ajax php代码就会根据您的需求进行更改。演示:http://theonlytutorials.com/jquery-ajax-file-upload-with-percentage-progress-bar/
https://stackoverflow.com/questions/47812221
复制相似问题