Example code for uploading images in php. Example code for uploading images in php below is the example code for uploading images in PHP. The first page is the table single page upfiles_frm.php. Code Title: upload File: The second page is the example code for processing image uploads in php form
The following is the example code for uploading images in PHP. The first page is the table single page upfiles_frm.php.
Code
Title:
Upload files:
The second page is processing the single page of the table upfiles_add.php
Code 1
2 $ mkdir_file_dir = mkdir ('./img/'. $ _ POST ['title'], 0777); // create an image-related directory when uploading a file
3 $ tmp_file_name = $ _ FILES ['file'] ['tmp _ name']; // temporary file name obtained after successful Upload
4 $ file_name = $ _ FILES ['file'] ['name']; // original file name
5
6 $ file_dir = '. /img /'. $ _ POST ['title']. '/'; // assign a created directory to a variable as the final storage directory
7
8 if (is_dir ($ file_dir ))
9 {
10 move_uploaded_file ($ tmp_file_name, $ file_dir. $ file_name); // start to move the file
11}
12?>
// Create a folder img under the file directory
Create a file and try again in the php environment!
The following is the example code for uploading images in PHP. The first page is the upfiles_frm.php page of the table. Code Title: upload File: The second page is processing form...