1、upload.php
<!DOCTYPE HTML "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Add文件上傳_www.jbxue.com</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <!--文件上傳要注意:1、要有enctyp,2、method="post"--> <form enctype="multipart/form-data" action="uploadProcess.php" method="post" > <table> <tr><td>請填寫用戶名</td><td><input type="text" name="username"></td></tr> <tr><td>請簡單介紹文件</td><td><textarea rows="7" cols="50" name="fileintro" 2、uploadProcess.php<? =['username'=['fileintro' =['myfile']['size'(>2*1024*1024 "<script type='text/javascript'>window.alert('文件不能大於2M')</script>" =['myfile']['type'(!="image/jpeg" && !="image/pjpeg" "文件類型只能是 jpg 格式" ((['myfile']['tmp_name' =['myfile']['tmp_name' =['DOCUMENT_ROOT']."/file/up/".(!( ( =['myfile']['name'=."/".().(1,1000).(,(,"." ((,("utf-8","gb2312","" ['myfile']['name']."上傳成功" "上傳失敗" "上傳失敗"?><? ; ; ->upload_name=['myfile']['name'->upload_tmp_path=['myfile']['tmp_name'->file_size=['myfile']['size'->file_type=['myfile']['type'->allow_file_type = ('jpeg','jpg','png','gif','bmp','doc','zip','rar','txt','wps','xlsx','ppt'->file_save_path=['DOCUMENT_ROOT']."/file/up/" upload_file( (->file_size>2*1024*1024 "<script type='text/javascript'>window.alert('文件不能大於2M')</script>" =->getFileExt(->(!(,-> "上傳文件類型格式錯誤" ((-> =->file_save_path.(!( ( =."/".().(1,1000).(->upload_name,(->upload_name,"." ((->upload_tmp_path,("utf-8","gb2312","" ->upload_name."上傳成功" "上傳失敗" "上傳失敗" getFileExt(=( ["extension"?>