php文件分片上传,断点续传【实用版】

 

添加课程(课程可以添加多个)
  • ❶视频上传>
  • ❷视频压缩
视频标题:*
选择视频:*
上传进度: 0%
缩略图: 系统自动截图
视频时长: 系统自动获取
视频发布:

 

elseif ($_REQUEST['act'] == 'upload')
{
    //echo "aaaaa"; exit();
    $goods_id=isset($_REQUEST['goods_id'])?intval($_REQUEST['goods_id']):0;
    $video_id=isset($_REQUEST['videoid'])?intval($_REQUEST['videoid']):0;

    if($goods_id==0 && $video_id==0){
        echo 1;
        exit;
    }
//    $sql="SELECT goods_video FROM ".$ecs->table("goods")." WHERE goods_id=".$goods_id;
//
//    $sql1="SELECT goods_name FROM ".$ecs->table("goods")." WHERE goods_id=".$goods_id;

    //$yuan=iconv('UTF-8','gb2312//IGNORE',$db->getOne($sql));//通过商品id 查询该商品的视频

    //$goods_name=$db->getOne($sql1);

    //$yuan_dir="uploads/";//获得文件断点续传储存路径

    $dir1=iconv('UTF-8','gb2312//IGNORE',$_POST['filename']);//用于中文转码
    //ignore的意思是忽略转换时的错误,如果没有ignore参数,所有该字符后面的字符串都无法被保存
    //允许上传的文件扩展名
    $file_type = array( '.flv' ,'.rmvb' , '.mp4' );
    $filetype='.'.substr(strrchr($dir1, "."),1);//截取获得文件后缀名

    if(!in_array($filetype,$file_type))
    {
        echo "none";
        return false;
        die;
    }
    $basedir="..";

    //$dir2=$name.'video_'.time().$filetype;
    $dir="/uploads/".md5($dir1);
    //还原文件原名
    file_exists($basedir.$dir) or mkdir($basedir.$dir,0777,true);
    $path=$basedir.$dir."/".$_POST['blobname'];
    //$sql="UPDATE ".$ecs->table('lesson_goods')." SET goods_video='".$dir2."' WHERE goods_id=".$goods_id;
    //echo $sql;die;
    move_uploaded_file($_FILES["file"]["tmp_name"],iconv('UTF-8','gb2312//IGNORE',$path));


    if(isset($_POST['lastone'])){
        $title=isset($_POST['title'])?$_POST['title']:"";
        $yasuo=isset($_POST['yasuo'])?intval($_POST['yasuo']):0;
        $state=isset($_POST['state'])?intval($_POST['state']):0;
        //exit();
        $name="/uploadsvideo/video/".date('Ymd',time()).time()."/";
        if(!is_dir($basedir.$name)){
            mkdir($basedir.$name);
        }
        $dir2=$name.'video'.$filetype;
        //var_dump($_POST['videoid']);

        $count=$_POST['lastone'];
        if(!file_exists($basedir.$name)){mkdir($basedir.$name,0777,true);}
        $fp   = fopen($basedir.$dir2,"abw");
        for($i=0;$i<=$count;$i++){
            $handle = fopen($basedir.$dir."/".$i,"rb");
            fwrite($fp,fread($handle,filesize($basedir.$dir."/".$i)));
            fclose($handle);
            @unlink($basedir.$dir."/".$i);
        }
        fclose($fp);
        rmdir($basedir.$dir);
        $video_url="";
        $sql="";

        //通过文件是否存在 判断是否上传完成
        if(file_exists($basedir.$name))
        {
            echo $dir2; //'上传完成';
        }

    }
}

 

你可能感兴趣的:(FFmpeg)