<html>
<body><form action="" method="post" enctype="multipart/form-data"><input type="file" name="upfile"/><input type="submit" name="submit" value="上传"/></form><?phpif(!empty($_FILES['upfile']['name'])){ if(!is_dir("upfile/")) { mkdir("upfile/"); }$path="upfile/".time().$_FILES['upfile']['name'];if(is_uploaded_file($_FILES['upfile']['tmp_name'])) { if(!move_uploaded_file($_FILES['upfile']['tmp_name'],$path)) { echo "文件上传失败"; }else{ echo "上传成功"; foreach($_FILES['upfile']as $name=>$value){ echo $name.'='.$value.'<br/>'; } } }else { echo "上传文件".$_FILES['upfile']['name']."不合法。"; }}echo "预览:<img src=".$path.">"?></body></html>