php文件上传示例。。。

php文件上传示例。。。



[复制到剪切板]
CODE:
<?php
/*
抛个砖,具体要做成什么样自己做。
*/

if(isset($_FILES['userfile']['tmp_name'])){
$userfile $_FILES['userfile']['tmp_name']; //保存在系统的临时位置
$userfile_name $_FILES['userfile']['name'];//文件名
$userfile_size $_FILES['userfile']['size'];//文件大小,字节
$userfile_type $_FILES['userfile']['type'];//文件类型

if(!is_dir("image")) mkdir ("image"0700);
$upfile "image/".$userfile_name;//保存位置
//print_r($_FILES);

//move_uploaded_file($userfile,$upfile);//方法1

if(!copy($userfile,$upfile))//方法2
{
echo 
"上传失败";
exit();
}
echo 
"上传成功";
echo 
"<a href=\"#\" onClick=\"window.history.back();\">再上传一张</a>";
}
else{
?>
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<
title>无标题文档</title>
</
head>

<
body>
<
form action="" method="post" enctype="multipart/form-data" name="form1">
  <
input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="1000">
  <
input name="userfile" type="file" id="userfile">
  <
input type="submit" name="Submit" value="上传">
</
form>
</
body>
</
html>
<?
php }?> ;

如履薄冰

错错错........

如履薄冰

没错

大概思路没错,路径设好了就行

不会错的。。
如履薄冰