<?php 
require '../conn/conn.php';
require '../conn/function.php';

$S_filetype="jpg,jpeg,png,gif,bmp,ico,xls,xlsx,txt,sql,csv,mp4,rar,apk,doc";
$id=$_GET["id"];
$path=$_GET["path"];
$path = str_replace("@@", "..", $path);
$processid=$_GET["processid"];

$kname=strtolower(end(explode('.', $_POST['filename'])));

$k=$processid.".".$kname."_temp";
$g=date("YmdHis",time()).gen_key(2).".".$kname;

if(strpos($S_filetype,strtolower($kname))!==false){
  if (strpos($path, "../") !== false) {
      $p = $path;
  } else {
      $p = $_SERVER["DOCUMENT_ROOT"] . $path;
  }

if (preg_match('/asp|php|apsx|asax|ascx|cdx|cer|pht|htaccess|cgi|jsp/i', $k)) {
    die("error|上传文件格式不允许！");
} else {
  if(!file_exists($p . "/" . $k)){ 
    move_uploaded_file($_FILES['video']['tmp_name'],$p . "/" . $k); 
  }else{ 
    file_put_contents($p . "/" . $k,file_get_contents($_FILES['video']['tmp_name']),FILE_APPEND); 
  } 

  if(filesize($p . "/" . $k)==$_POST['size']){
  rename($p . "/" . $k,$p . "/" . $g);
  echo $g;
  }
}
}else{
  echo "error|文件格式不支持";
}

?>