The following is the implementation of the image upload in PHP instance code, the first page is the form page upfiles_frm.php.
Code
Title:
Upload file:
The second page is to process the form page upfiles_add.php
Code 1
2 $mkdir _file_dir = mkdir ('./img/'. $_post[' title '],0777); When you upload a file, you start creating a picture-related directory.
3 $tmp _file_name = $_files[' file ' [' Tmp_name ']; Temporary file name after successful upload
4 $file _name = $_files[' file ' [' Name ']; The original file name
5
6 $file _dir = './img/'. $_post[' title '. /'; Assign a value to a directory you create a variable as the final save directory
7
8 if (Is_dir ($file _dir))
9 {
Move_uploaded_file ($tmp _file_name, $file _dir. $file _name); Start moving files
11}
?>
Create a folder in the file directory img
Then create the file, in the PHP environment, try again!