Home >Backend Development >PHP Tutorial >PHP upload video_PHP tutorial

PHP upload video_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:52:441647browse

网页教学网(webjx.com)文件上传实例

 

 

 


upfile.php.

function getname($exname){

   $dir = "./uploadfile/";

   $i=1;

   if(!is_dir($dir)){

      mkdir($dir,0777);

   }


   while(true){

     if(!is_file($dir.$i.".".$exname)){

        $name=$i.".".$exname;

        break;

      }

     $i++;

   }


   return $dir.$name;

}


$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));

$uploadfile = getname($exname); 


if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) {

   echo "

文件上传成功!



";

}else {

   echo "

文件上传失败!



";

} echo "下面是文件上传的一些信息:

原文件名:".$_FILES['upfile']['name'] ."

类型:" .$_FILES['upfile']['type'] ."

临时文件名:".$_FILES['upfile']['tmp_name']. "

文件大小:".$_FILES['upfile']['size']."

错误代码:".$_FILES['upfile']['error'];
?>


作者:nycqwert

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478086.htmlTechArticlehtml head meta http-equiv=Content-Type content=text/html; charset=gb2312 title网页教学网(webjx.com)文件上传实例/title /head body form enctype=multipart/form-data action=...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn