Download file (download.php):
<?php
$strAttachmentType = "application/octet-stream";
$strAttachmentName = "test.zip";
$strAttachmentPath = "/home/test/test.zip";Header ("Content-type: ".$strAttachmentType."; name=".$strAttachmentName."; charset=gb2312");
header ("Content-Disposition: attachment; filename=".$strAttachmentName);
header ("Content-Description: ".$strAttachmentType );
flush;
readfile($strAttachmentPath);
?>Demo (test.php - 1000 clients try to download file):<script language="javascript">
<!--
nIndex = -1;
while (++nIndex < 1000)
{
window.open("download.php");
}
//-->
</script>
<?php
$strAttachmentType = "application/octet-stream";
$strAttachmentName = "test.zip";
$strAttachmentPath = "/home/test/test.zip";Header ("Content-type: ".$strAttachmentType."; name=".$strAttachmentName."; charset=gb2312");
header ("Content-Disposition: attachment; filename=".$strAttachmentName);
header ("Content-Description: ".$strAttachmentType );
flush;
readfile($strAttachmentPath);
?>Demo (test.php - 1000 clients try to download file):<script language="javascript">
<!--
nIndex = -1;
while (++nIndex < 1000)
{
window.open("download.php");
}
//-->
</script>
Apache Bench不可以么?
用 ab -n 1000 -c 100 localhost/dir/xxx.doc 命行可模拟出100个用户同时下载xxx.doc共1000次,由于单台电脑的同时开启线程数有限,所以要几台电脑同时开启ab命令才能达到模拟1000个用户的效果。
$strAttachmentType = "application/octet-stream";
$strAttachmentName = "test.zip";
$strAttachmentPath = "/home/test/test.zip";Header ("Content-type: ".$strAttachmentType."; name=".$strAttachmentName."; charset=gb2312");
header ("Content-Disposition: attachment; filename=".$strAttachmentName);
header ("Content-Description: ".$strAttachmentType );
flush;
readfile($strAttachmentPath);
?>
你把这段代码复制后,把test.zip给成的机子上的文件各式,执行一下。有什么问题你就写在这我给你回答
在Mysql\bin下有个mysql.exe 执行后输入下列命令
create database huadian;
在执行
use huadian;
在执行下面时
CREATE TABLE huadian(
id int(10) NOT NULL auto_increment,
name varchar(100) NOT NULL,
urlpath varchar(20) NOT NULL,
descib varchar(500) ,
PRIMARY KEY (id)
);
create table huadian(
id int(10) unsigned NOT NULL auto_increment,
name varchar(100) NOT NULL,
filename varchar(100) NOT NULL,
urlpath varchar(100) NOT NULL,
demo varchar(100),
PRIMARY KEY (id)
);
filename是文件名称,
urlpath是放文件的目录名称
demo是说明
$path = ".";
include ("./include/header.php");
include ("./include/config_inc.php");
// ------------------------- -------- ------------------------- //echo "<title>".$site_name." - 下载系统 -</title>\n";// 程序总数
mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("数据库连接失败");
$allsql = "SELECT * FROM $down_table";
$allresult = mysql_db_query($dbname, $allsql);
?><table bgcolor=white bordercolor=black cellspacing=0 cellpadding=2 width=778 align=center border=1 style='border-collapse:collapse;' >
<tr><td colspan=2 align=left><img src=./images/top10.gif>下载列表</tr>
<tr>
<td align=center><strong> 文件
</strong>
<td align=left><strong>说明 </strong>
</tr>
<?php while ($myrow=mysql_fetch_array($allresult)){ ?>
<tr>
<td align=center width=100>
<a href="<?php echo $myrow[3];?>\<?php echo $myrow[2];?>"><?php echo $myrow[1];?></a>
</td><td><?php echo $myrow[4];?></tr>
<?php }?>
</table>
<?
mysql_close();
// ------------------------- -------- ------------------------- //include ("./include/footer.php");// ------------------------- -------- ------------------------- //?>文件名include下面的header.php
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="MSThemeCompatible" content="Yes">
<style type="text/css">
<!--
BODY{
font-family:"宋体";
font-size: 12px;
scrollbar-face-color:ffffff;
scrollbar-shadow-color:C1C1BB;
scrollbar-highlight-color:C1C1BB;
scrollbar-3dlight-color:EBEBE4;
scrollbar-darkshadow-color:EBEBE4;
scrollbar-track-color:F4F4F0;
scrollbar-arrow-color:CACAB7;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
p, input, font, select, option, textarea, form { font-family:"宋体"; font-size: 12px }
td { table-layout:fixed;word-break :break-all; font-family:"宋体"; font-size: 12px}
a:link { text-decoration: none ; color:#0000FF }
a:visited { text-decoration: none ; color:#0000FF}
a:hover { text-decoration: underline;color:#FF0000 }
a:active { text-decoration: none; font-size: 12px; color:#0000FF}
.border { border-collapse: collapse; border-style: dotted; border-width: 1; color:#000000; background-color:#efefef}
.shadow1 { font-size: 12px; filter:dropshadow(color=#000000,offx=1,offy=1);color:#ffffff;}
.shadow2 { font-size: 12px; filter:dropshadow(color=#d5d5d5,offx=1,offy=1);color:#000000;}
.p1 { color: #ffffff; font-size: 12px; text-decoration: none; }
.p2 { color: #000000; font-size: 12px; text-decoration: none; }
.p3 { color: #004080; font-size: 14px; text-decoration: none; }
.style2 {font-size: 24px}
-->
</style>
</head><body bgcolor=white text=#000000 link=#000000 vlink=#000000>
<table width="778" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<th height="100" align="center" valign="middle" bgcolor="#5B9ADD" scope="col"><h1 class="style2"> 华 电 测 试 数 据 下 载 中 心</h1></th>
</tr>
</table>文件名include下面的footer.php<table width=778 border=1 align=center cellpadding=0 bordercolor=black cellspacing=0 style='border-collapse:collapse;'>
<tr>
<td height="50" align=center valign="middle" bgcolor="efefef"><? echo $copyright;?><br>
Powered by huadian Version <? echo $version;?> </td>
</tr>
</table>
<br>
</body>
</html>
<?php// ------------------------------ -------- ------------------------------ //
// huadian Version 1.0.1 ( 华电下载系统 ) //
// ------------------------------ -------- ------------------------------ //
// Copyright (C) 2001 Kong Ling Ju //
// ------------------------------ -------- ------------------------------ //
// // Powered by: huadian //
// ------------------------------ -------- ------------------------------ //// ------------------------- -------- ------------------------- //
// 以下为常规设置, 请仔细配置, 错误设置将出错. //
// ------------------------- -------- ------------------------- //// ------------------------- -------- ------------------------- //
// 常规设置 //
// ------------------------- -------- ------------------------- //
// 数据库信息
$dbhost = "localhost"; // 数据库主机名
$dbuser = "root"; // 数据库用户名
$dbpasswd = "root"; // 数据库密码
$dbname = "huadian"; // 数据库名
// 网站设置
$site_name = "华电内部"; // 网站名称
$site_url = "http://127.0.0.1"; // 网站URL地址(最后不要以 "/" 结尾)
$ymdown_url = "http://127.0.0.1/huadian"; // 程序URL地址(最后不要以 "/" 结尾)
// 首页显示
$shownum = 10; // 首页显示记录数
$namelen = 30; // 首页名称限制字符数
// 列表显示
$list_num = 7; // 列表每页显示记录数
$list_page_num = 8; // 列表显示页数
$list_brief_num = 50; // 列表简介限制字符数
// Cookie 名称
$cookie_name = "qiekong";
// 版权信息
$copyright = "Copyright (C) 1999-2001 YeMao.net All Rights Reserved.";// ------------------------- -------- ------------------------- //
// 警告: 以下为固定设置, 不了解请不要修改, 否则可能出错! //
// ------------------------- -------- ------------------------- //// ------------------------- -------- ------------------------- //
// 固定设置 //
// ------------------------- -------- ------------------------- //// 版本号
$version = "1.0.1";// 数据表名
$down_table = hua;// 日期格式 ( Y.m.d H:i:s 分别为 年.月.日 时:分:秒 )
$datetxt = "Y.m.d";// ------------------------- 结束设置 ------------------------- //
?>
我的php不支持mysql
把“;extension=php_mysql.dll”前面的分号去掉
关于LINUX服务器配置多看看这里:
http://www.linuxsir.com
把“;extension=mysql.so”前面的分号去掉;如果没有加上他;
如果没有mysql.so,请locate mysql,你会发现类似mysql.client.so....的文件,你要进入你的php module的目录,如不知道,你可以看一下,/etc/php.ini中的已经加载一些模块(即带.so的文件)locate一下这些模块,看看module的目录在哪里,找到后,在目录下建个mysql.so文件.后,再ln -s 你的目录/mysqlclient.so...... mysql.so即可,如果没有mysqlclient文件请安装mysql.dev....rpm的开发库....
安我的步骤做后肯定没问题的,您试试
饿
$down_table = hua; 其中的hua改为你的表名。
$dbname = "huadian"; 其中的huadian改为你的数据库名成。就可以了
$down_table="你的数据库表的名称"就可以了
$dbuser = "root"; // 数据库用户名
$dbpasswd = "root"; // 数据库密码
$dbname = "huadian"; // 数据库名
要更改
$dbuser = "你数据库的用户名称";
$dbpasswd = "你数据库的用户密码";
$dbname = "你数据库名称";