Script for creating the file exchange function (1)

Source: Internet
Author: User

For work reasons, you need to install a file exchange item on the LAN, or you can create a function block for downloading files.
PHP, MySQL, and Apache are used. Program Post the compilation process because some Oso Article Is 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 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

<HTML>
<Body bgcolor = "# ffffff">
<Head>
<Title> file exchange </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>

<Div align = "center">
<Table width = "500" border = "0" cellspacing = "0" cellpadding = "0" Height = "25">
<Tr>
<TD Height = "25">
<Div align = "center"> file exchange zone </div>
</TD>
</Tr>
</Table>
<Table width = "600" border = "0" cellspacing = "0" cellpadding = "0" Height = "20">
<Tr>
<TD Height = "25" width = "75">
<Div align = "center"> <a href = "Upload. php"> upload a file </a> </div>
</TD>
</Tr>
</Table>
<Table width = "600" border = "0" cellspacing = "0" cellpadding = "0" Height = "79">
<Tr valign = "TOP">
<TD>
<Div align = "center"> <?
$ 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 "<Table border = 1> \ n ";
Echo "<tr> <TD> file name </TD> <TD> upload date </TD> <TD> uploaded by </TD> <TD> file description </TD> <TD> file type </TD> </tr> \ n ";
Do
{
Printf ("<tr> <TD> <a href = \".. /file/% s \ "> % S </a> </TD> <TD> % S </TD> <TD> % S </TD> <TD> % S </TD> </tr> \ 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 "</table> </P> \ n ";
}
Else
{
Echo "no file in the file exchange area <br> <a href = 'index. php'> return </a> ";
}
?> </Div>
</TD>
</Tr>
</Table>
</Div>
</Body>
</Html>

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.