PHP+Ajax异步带进度条上传文件
                                            前端引入文件
成都创新互联服务项目包括乌拉特后网站建设、乌拉特后网站制作、乌拉特后网页制作以及乌拉特后网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,乌拉特后网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到乌拉特后省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Ajax进度条异步处理
前端上传HTML
文件上传
Ajax Image Uploader
A simple tutorial to explain p_w_picpath uploading using jquery ajax and php
0% Complete
PHP文件上传类
'empty_name','type'=>$type);
             echo json_encode($arr);
             exit();
        }
	return true;
}
 //检测文件类型
 public function check_type($get_type)
 {
	  if (( $get_type == ".docx" ) || ( $get_type == ".doc" )) {
	       #$types = $get_type;
	  }else{
	       $type = "check_type";
	       $arr = array('error'=>'format','type'=>$type);
               echo json_encode($arr);
               exit();	
     }
   return true;
 }
 //检测文件大小
 public function check_size($get_file)
 {
	 if ( $get_file != "" ) {
            if ( $get_file > $this->file_size ) {
                   $arr = array('error'=>'large');
                   echo json_encode($arr);
                   exit();
            }
    }else{
		return false;
		exit();
	}
  return true;
 }
   
//文件保存
 public function save_file($file_type,$file_tmp_name)
 {
	$rand = rand(1000, 9999);
	$pics = date("YmdHis") . $rand . $file_type;
	$path = $this->file_path."/".$pics;
	$result = move_uploaded_file($file_tmp_name, $path);
	if($result){
		return $pics;
	}else{
		return false;
		exit();
	}
	#return $pics;
 }
 
}PHP文件上传处理
check_file($get_fileName);
if($check_result){
    //检查文件类型
	$result_type = $up_obj->check_type($get_fileType);
	//检查文件大小
	if($result_type){
		$result_size = $up_obj->check_size($get_fileSize);
		if($result_size){
			//文件上传保存	
			$pics = $up_obj->save_file($get_fileType,$get_TmpFiles);		
			$size = round($get_fileSize/1024,2);
 	                $arr = array(
 		                'name' => $get_fileName,
		                 'pic' => $pics,
		                 'size'=> $size,
		                 'error' => 2
		         );
			 //检查文件上传状态
			 if($pics){
		         echo json_encode($arr);
				 /*
				 执行上传完成逻辑.....
				 */
			}		
		}
    }
}文件上传效果如图:

当前题目:PHP+Ajax异步带进度条上传文件
转载注明:http://www.cqwzjz.cn/article/pdoocp.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 