Home > Backend Development > PHP Tutorial > QQ group cannot upload files. To upload files, first create a directory and then upload it to the directory.

QQ group cannot upload files. To upload files, first create a directory and then upload it to the directory.

WBOY
Release: 2016-07-29 08:44:00
Original
1383 people have browsed it

1. Form part:

Copy the code The code is as follows:




<br>my is upfile app!! <br>



File name:
Upload file:





2, process the form page:

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template