Example code for uploading images in PHP
The following is a PHP implementation of image upload instance code, the first page is the form page upfiles_frm.php.
Code
Title:
Upload file:
The second page is the Processing form page upfiles_add.php
Code 1
2 $mkdir _file_dir = mkdir ('./img/'. $_post[' title '],0777); When uploading a file, start creating an image-related directory
3 $tmp _file_name = $_files[' file ' [' Tmp_name ']; Temporary file name to be taken after successful upload
4 $file _name = $_files[' file ' [' Name ']; The original file name
5
6 $file _dir = './img/'. $_post[' title '. ' /'; Assign the created directory to a variable as the final save directory
7
8 if (Is_dir ($file _dir))
7 5
Ten Move_uploaded_file ($tmp _file_name, $file _dir $file _name); Start moving files
11}
?>
Create a folder in the file directory img
Then build the file, in PHP environment, try again!
http://www.bkjia.com/PHPjc/847203.html www.bkjia.com true http://www.bkjia.com/PHPjc/847203.html techarticle PHP Implementation of image upload instance code The following is a PHP implementation of image upload instance code, the first page is a form page upfiles_frm.php. Code title: Upload file: The second page is to process the form ...