Script for creating the file exchange function (1) _ PHP Tutorial

Source: Internet
Author: User
Script for creating the file exchange function (1 ). For work reasons, you need to install a file exchange item on the LAN, or you can create a function block for downloading files. Using php, mysql, and apache, you can install a file exchange on the LAN for working reasons. you can also create a function block for downloading files.
I am using php, mysql, and apache to post the programming process, because some articles on oso for this reference are also a supplement,
I also pay tribute to my predecessors.

Prepare to create an upfile table in your mysql yourdatabase database.
/* Upload a file table
Create table upfile (
Id TINYINT (8) not null AUTO_INCREMENT, // id of the file
Filename VARCHAR (80) not null, // file name
Fileshow VARCHAR (80) not null, // File description
Date DATE not null, // upload date
Uploader VARCHAR (40) not null, // uploaded signature
Type VARCHAR (40) not null, // file type (manually defined)
Primary key (id)
)
*/

// This is the main page of the program, used to display uploaded files.
// Index. php




File Exchange










File Exchange zone








Upload files








$ Db = mysql_connect ("$ hostname", "$ user", "$ password") or die ("unable to connect to database"); // connect to the library
Mysql_select_db ("yourdatabse", $ db) or die ("unable to open database ");
$ SQL = "select * from upfile ";
$ Result = mysql_query ($ SQL );
If ($ myrow = mysql_fetch_array ($ result ))
{
Echo"









\ N ";Echo" \ N ";Do{Printf (" \ N ", $ myrow [" filename "], $ myrow [" filename "], $ myrow [" date "], $ myrow [" uploader "], $ myrow ["fileshow"], $ myrow ["type"]);}// List all files for download.While ($ myrow = mysql_fetch_array ($ result ));Echo"
File name Upload date Uploaded File description File type
% S % S % S % S % S

\ N ";
}
Else
{
Echo "no file in the file exchange zone
Return ";
}
?>






Bytes. Php, mysql, and apache are used to compile the program...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.