1. Form part:
Copy the code The code is as follows:
Copy the code The code is as follows:
< ;?php
$mkdir_file_dir = mkdir('./img/'.$_POST['title'],0777); //Get the title and create a folder under the final directory to store the files specified by the category
$tmp_file_name = $_FILES['file']['tmp_name']; //Get the uploaded temporary file
$file_name = $_FILES['file']['name']; //Source file
$file_dir = ' ./img/'.$_POST['title'].'/'; //Final save directory
if(is_dir($file_dir))
{
move_uploaded_file($tmp_file_name,$file_dir.$file_name); //Move File to the final saving directory
$img_url = $file_dir.$file_name;
$link = mysql_connect("localhost","root","");
mysql_select_db("fenye");
mysql_query("set names utf8") ;
$insert = "insert into upfiles(title,img_url) values ('{$_POST['title']}','{$img_url}') ";
mysql_query($insert); //Save the file path To the database
}
?>
The above has introduced the problem that the QQ group cannot upload files. To upload files, first create a directory and then upload it to the directory. This includes the content of the QQ group that cannot upload files. I hope it will be helpful to friends who are interested in PHP tutorials.