php:檔案系統③

來源:互聯網
上載者:User
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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.