PHP: File System ③

Source: Internet
Author: User
Html>< HTML lang= "en">< Head> < Meta charset= "UTF-8"> < title> VIEW Title> < 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: + px; font-family: Chinese Choi Wan; "> File Upload Font> Td> Tr> < TR>< TD> Please enter user name: Td>< TD>< input type= "Text" name= "username"/> Td> Tr> < TR>< TD> Please briefly describe the file Td>< TD>< textarea rows= "Ten" cols= "Max" name= "Fileintro"> TextArea> Td> Tr> < TR>< TD> Please select the uploaded file: Td>< TD>< input type= "File" name= "MyFile"/> Td> Tr> < TR>< TD>< input type= "Submit" value= " Upload "> Td>< TD> Td> Tr> Table> Form> Div> Body> Html> $username=$_post[' username '); $fileintro=$_post[' Fileintro ']; echo $username. $fileintro; Echo "
"; Print_r ($_files); "
"; // when uploading large files, you need to php.ini Modified in post_max_size And upload_max_filesize Parameters$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 ']; // Avoid overwriting the same name file uploaded by the same user; $move _to_file = $user _path . "/" . Time () . Rand ( 1 , + ) . substr ($fileName, strrpos ($fileName, "." )); if ( move_uploaded_file ($uploaded _file, $move _to_file)) { echo $_files[ ' myfile ' [ ' name ' ] . " upload ok ;} Else { echo ' upload failed " ;}} Else { echo "FAILED" ;}

above introduces PHP: File system ③, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.