一个PHP上传的小程序
Uploading...
if($_FILES['userfile']['error']>0) { echo 'problem:'; switch($_FILES['userfile']['error']) { case 1: echo '不能上传!'; break; case 2: echo '文件大小超范围!';break; case 3: echo '文件只上传了一部分!';break; case 4: echo '没有选择文件!';break; } exit; } $upfile='upload/'.$_FILES['userfile']['name']; if($_FILES['userfile']['type']=='text/plain' or $_FILES['userfile']['type']=='image/gif' or $_FILES['userfile']['type']=='application/octet-stream' or $_FILES['userfile']['type']=='application/x-zip-compressed') //控制文件上传类型 { if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { if(!move_uploaded_file($_FILES['userfile']['tmp_name'],$upfile)) { echo '文件不能上传至服务器!'; exit; } } else { echo '文件不能上传,文件名为:'; echo $_FILES['userfile']['name']; exit; } echo $_FILES['userfile']['name'].'文件上传成功!'; echo ""; } else { echo '文件类型不对!'; exit; } [/code] 页面三:browsedir.php //浏览已上传的文件; [code]文件上传至文件夹$current_dir
"; echo "目录为:
- ";
while($file=readdir($dir))
{
echo "
- $file "; } echo "