Script to establish file Exchange (i) _php Foundation

Source: Internet
Author: User
Because the reason for the work needs to install a file exchange on the local area network thing, also can make a file to download the function block.
With the Php,mysql,apache is now the process of writing out, because this reference to Oso some of the articles, is also a supplement,
Also express my respect for the predecessors.

Prepare to build a table in your MySQL yourdatabase library upfile
/* Upload File Table
CREATE TABLE Upfile (
ID TINYINT (8) NOT NULL auto_increment,//file ID number
FileName VARCHAR NOT NULL,//filename
Fileshow VARCHAR NOT NULL,//File description
Date date not NULL,//upload dates
Uploader VARCHAR NOT NULL,//upload signature
Type VARCHAR NOT NULL,//file type (human-defined)
PRIMARY KEY (ID)
)
*/

This is the main page of the program to display the uploaded files.
index.php

<body bgcolor= "#FFFFFF" >
<title> File Exchange </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">


<div align= "center" >
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "height=" >
<tr>
&LT;TD height= ">"
<div align= "Center" > File Exchange Area </div>
</td>
</tr>
</table>
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "height=" >
<tr>
&LT;TD height= "Width=" >
<div align= "center" ><a href= "upload.php" > Upload file </a></div>
</td>
</tr>
</table>
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "height=" >
&LT;TR valign= "Top" >
<td>
<div align= "center" &GT;&LT;?
$db =mysql_connect ("$hostname", "$user", "$password") or Die ("Unable to connect to the database"); Connecting to the Library
mysql_select_db ("Yourdatabse", $db) or Die ("Cannot open database");
$sql = "SELECT * from Upfile";
$result =mysql_query ($sql);
if ($myrow = mysql_fetch_array ($result))
{
echo "<table border=1 >\n";
echo "<tr><td> filename </td><td> upload date </td><td> upload </td><td> file Description </td ><td> file Type </td></tr>\n ";
Todo
{
printf ("<tr><td><a href=\"). /file/%s\ ">%s</a></td><td>%s</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 the files to provide downloads.
while ($myrow = Mysql_fetch_array ($result));
echo "</table></p>\n";
}
Else
{
echo "File Exchange area does not have file <br><a href= ' index.php ' > Return </a>";
}
?></div>
</td>
</tr>
</table>
</div>
</body>

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.