//do.php executes the uploaded file
When you press the submit button, the file will be uploaded from your computer to the temporary directory of the server.
The file name in the temporary directory is a temporary file. It should be accessed using the name value of the file field, in this case $myfile.
The real file name is accessed using the name value of the file field plus "_name", in this case $myfile_name.
Use the copy() function to copy the temporary file $myfile to the specified directory. The copied file name is $myfile_name.
Don’t forget to delete the temporary files when finished, otherwise you will have a lot of files you don’t want.
In addition, you must have read and write permissions on the directory you specify. Here it is /usr/local/apache/htdocs/file/
Save file //Automatically jump to index.php after 3 seconds
$db=mysql_connect("$hostname","$user","$password")or die("Unable to connect to database");
mysql_select_db("yourdatabase",$db) or die("Unable to open database");
If($myfile != "none") {
copy($myfile,"/usr/local/apache/htdocs/file/$myfile_name");// Copy the temporary file to the directory you specified.
unlink($myfile);//Delete the temporary file
$sql="insert into upfile (id,filename,fileshow,date,uploader,type) values (' ','$myfile_name','$fileshow','$date','$uploader','$type')";
$result=mysql_query($sql);
echo "File uploaded successfully, Return to the main page after three seconds";
}
else {
echo "File upload failed, return to the main page after three seconds";
}
?>
< /center> Remove the ; in front of /tmp, and add the directory where the temporary files you want to use are at the end.
Also remove the “;” in front of upload_max_filesize =100M, and then add the maximum size of the file you want users to upload at the end.
I am using 100M, which is enough. ^_^.
http://www.bkjia.com/PHPjc/315754.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/315754.htmlTechArticle//do.php executes the uploaded file. When you press the submit button, the file will be downloaded from your The computer uploads it to the temporary directory of the server. The file name in the temporary directory is a temporary file...