With PHP, you can upload files to the server.
Test project, the directory structure is:
Test
|-----Upload # File uploaded directory
|-----form.html # form File
|-----upload_file.php # PHP upload code
form.html # Form File
"Utf-8"><title> Rookie Tutorial (runoob.com) </title>"upload_file.php"Method="Post"Enctype="Multipart/form-data"> <label for="file"> FileName:</label> <input type="file"Name="file"Id="file"><br> <input type="Submit"Name="Submit"Value="Submit"></form></body>upload_file.php # PHP upload code
<?PHP//allow uploading of picture suffixes$allowedExts = Array ("gif","JPEG","jpg","PNG"); $temp= Explode (".", $_files["file"]["name"]); Echo $_files["file"]["size"]."<br>"; $extension= End ($temp);//get file suffix nameif((($_files["file"]["type"] =="Image/gif")|| ($_files["file"]["type"] =="Image/jpeg")|| ($_files["file"]["type"] =="image/jpg")|| ($_files["file"]["type"] =="Image/pjpeg")|| ($_files["file"]["type"] =="Image/x-png")|| ($_files["file"]["type"] =="Image/png"))&& ($_files["file"]["size"] <204800)//Less than KB&&In_array ($extension, $allowedExts)) { if($_files["file"]["Error"] >0) {echo"Error::". $_files["file"]["Error"] ."<br>"; } Else{echo"upload file name:". $_files["file"]["name"] ."<br>"; Echo"file type: the". $_files["file"]["type"] ."<br>"; Echo"File Size:". ($_files["file"]["size"] /1024x768) ."kb<br>"; Echo"location of temporary storage of files:". $_files["file"]["Tmp_name"] ."<br>"; //determine if the file exists in the upload directory under the current directory//If there is no upload directory, you need to create it, upload directory permission is 777 if(File_exists ("upload/". $_files["file"]["name"]) {echo $_files["file"]["name"] ."file already exists. "; } Else { //If the file does not exist in the upload directory, upload the file to the upload directoryMove_uploaded_file ($_files["file"]["Tmp_name"],"upload/". $_files["file"]["name"]); Echo"files are stored in:"."upload/". $_files["file"]["name"]; } }}Else{echo"Illegal file formats";}?>PHP File Upload