The following is an example code for image upload in PHP. The first page is the form page upfiles_frm.php.
Code
Title:
Upload files:
The second page is the processing form page upfiles_add.php
Code 1
2 $mkdir_file_dir = mkdir('./img/'.$_POST['title'],0777); //Start creating a picture-related directory when uploading files
3 $tmp_file_name = $_FILES['file']['tmp_name']; //The temporary file name after successful upload
4 $file_name = $_FILES['file']['name']; //Original file name
5
6 $file_dir = './img/'.$_POST['title'].'/'; //Assign the created directory to a variable as the final saving directory
7
8 if(is_dir($file_dir))
9 {
10 move_uploaded_file($tmp_file_name,$file_dir.$file_name); //Start moving files
11}
12 ?>
//Create a folder img in the file directory
Create the file again, try it again in the php environment!