html><html lang="en"><head> <meta charset="UTF-8"> <title>VIEWtitle> <link rel="stylesheet" href="???" type="text/css" />head><body><div class="register"> <form enctype="multipart/form-data" method="post" action="uploadprocess.php" name="myform"> <table> <tr><td align="center" colspan="2"><font style="
font-size: 40px;
font-family:華文彩雲;"> 檔案上傳font>td>tr> <tr><td>請輸入使用者名稱:td><td><input type="text" name="username" /> td>tr> <tr><td>請簡單介紹該檔案td><td><textarea rows="10" cols="40" name="fileintro" > textarea>td>tr> <tr><td>請選擇上傳的檔案:td><td><input type="file" name="myfile" /> td>tr> <tr><td><input type="submit" value="上傳">td><td> td>tr> table> form>div>body>html>$username=$_POST['username'];$fileintro=$_POST['fileintro'];echo $username.$fileintro;echo "
";print_r($_FILES);echo "
";//上傳大檔案時,需在php.ini中修改post_max_size和upload_max_filesize參數;$user_path=$_SERVER['DOCUMENT_ROOT']."/Hanshunping/UP/".$username;$user_path=
iconv("utf-8","gb2312",$user_path);if(!
file_exists($user_path)){
mkdir($user_path);}$fileName=$_FILES['myfile']['name'];$fileName=
iconv("utf-8","gb2312",$fileName);if(
is_uploaded_file($_FILES['myfile']['tmp_name'])){ $uploaded_file=$_FILES['myfile']['tmp_name']; //避免同一使用者上傳的同一名字檔案被覆蓋;$move_to_file=$user_path."/".
time().
rand(1,1000).
substr($fileName,
strrpos($fileName,".")); if(
move_uploaded_file($uploaded_file,$move_to_file)){ echo $_FILES['myfile']['name']."上傳OK"; }else{ echo "上傳失敗"; }}else{ echo "FAILED";}
以上就介紹了php:檔案系統③,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。