All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP上传文件的代码_php资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/21 22:24:49 Browse times: 349 Comment times: 0

PHP上传文件的代码_php资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

PHP上传文件的代码_php资料_编程技术-你的首页-uuhomepage.com
动态网站开发中,常用的PHP上传文件的代码实例。

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


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'];
?>





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.