Use PHP for file upload, mainly use the form function and PHP built-in $_files function function. Next we see how to implement PHP upload function. Example, this example is successful in debugging under a Mac.
PHP Upload image File function code is as follows:
FileExample</title> <style>body{Width:500px; Margin:20px Auto; Line-height:25px; } img{Display:Block; Max-width:500px; } h1{Text-align:Center; } #uploadfile{Background-color:#eee;Text-align:Center; Width:500px; Margin: 0Auto; } form{margin:0px; Padding:0px; } #uploadfile. input1{DisplayBlock; Width:500px; Text-align:Center; Margin: 0Auto; } #uploadfile. input2,.input3{Width100px; Margin:5px 20px; } </style>File$_server[' php_self '];? > "method=" POST "> <inputclass= "INPUT1" name= "upfile" type= "file" > <inputclass= "Input2" type= "Submit" value= "confirm Submission" > <inputclass= "INPUT3" type= "reset" value= "reset" > </form> </div> <?PHPif($_files["Upfile"] ["Name"]==NULL){ Echo"No file choice!"; }Else{ $filepath= "/library/webserver/documents/"; $tmp _name=$_files["Upfile"] ["Tmp_name"]; $filename=$filepath.$_files["Upfile"] ["Name"]; Echo"<br>". \$_files[' upfile ' [' Name ']: ".$_files["Upfile"] ["Name"]; Echo"<br>". \$_files[' upfile ' [' Size ']: ". GetSize ($_files["Upfile"] ["Size"]); Echo"<br>". \$_files[' upfile ' [' type ']: ".$_files["Upfile"] ["Type"]; Echo"<br>". \$_files[' upfile ' [' Tmp_name ']: ".$_files["Upfile"] ["Tmp_name"]; if(Move_uploaded_file($tmp _name,$filename)){ Echo"<br>". Uploaded to Directory: ".$filename; if(In_array($_files["Upfile"] ["Type"],Array("Image/png", "image/jpg", "Image/bmp"))){ Echo"<br>". $_files["Upfile"] ["Name"]. "' /> "; }Else{ } }Else{ Echo"<br>". Upload faild! "; } }//convert file size to corresponding unit of measure functionGetSize ($tmp){ $arr=Array("B", "KB", "MB", "GB", "TB", "PB"); $pos= 0; if(!Is_integer($tmp)) return-1; while($tmp>1024 andCount($arr) >$pos){ $tmp=$tmp/1024.0; $pos++; } $tmp=sprintf("%.2f",$tmp); return $tmp.$arr[$pos]; } ?></body>Use the form's action to submit an object to a form, like the example in this article, which submits the form to itself for processing.
Method can select a post or get file for submission.
How to use PHP to upload files, upload images, php upload tutorials, php form file upload Tutorial