file_up.php
<? PHP Header ("Content-type:text/html;charset=utf-8");? ><form action= "file_chuli.php" enctype= "Multipart/form-data" method= "POST" ><input type= "file" Name= " File "/><input type=" submit "value=" Upload "/></form>
View Code
file_chuli.php
<?PHPHeader("Content-type:text/html;charset=utf-8");/*$file = $_files["file"]; All information about the uploaded file is stored in the $_files["file"] array; echo $_files["File" ["Name"]; Take the filename echo $_files["file" ["type"]; Fetch file type echo $_files["file" ["Size"]; Fetch file size echo $_files["file" ["Tmp_name"]; File on the server temporary storage path echo $_files["file" ["Error"]; Upload error messages, no errors display 0*///File Upload if($_files["File"] ["Error"]){ Echo"Upload Error!" ";} Else{ //1. Restrictions on adding conditions if($_files["File"] ["type"] = = "Image/jpeg" &&$_files["File"] ["Size"]<2048000) { //2. Working with file names $str=Date("Ymdhisms", Time()); //3. Create a storage path $url= ".. /test/".$str.$_files["File"] ["Name"]; //4. Turn the path to GB to prevent file name garbled $filename=Iconv("Utf-8", "gb2312",$url); if(file_exists($filename)) { Echo"The file already exists"; } Else { //5. Storage Move_uploaded_file($_files["File"] ["Tmp_name"],$filename); Echo"Upload success!" "; } } Else { Echo"Upload file type does not meet the requirements"; } }?>View Code
PHP File Upload Processing