例子:用PHP实现上载任何类型的文件并可以直接显示或下载下来
时间:2007-02-17 来源:PHP爱好者
我这个程序可以让你上传任何类型的文件并可以直接显示或下载下来(upload_and_show.PHP3):
<?PHP
if($submit)
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("content-type:application/octet-stream");
header("content-disposition:inline;filename=$form_data");
header("content-description:PHP3 generated data");
$fd = fopen($form_data,"r");
while($string = fread($fd,200)){
echo $string;
}
fclose($fd);
}
else { ?>
<form method="post" action="<?PHP echo $PHP_self; ?>" ENCTYPE="multipart/form-data">
file description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>file to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?PHP } ?>
php爱好者站 http://www.phpfans.net Linux|Apache|IIS.
<?PHP
if($submit)
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("content-type:application/octet-stream");
header("content-disposition:inline;filename=$form_data");
header("content-description:PHP3 generated data");
$fd = fopen($form_data,"r");
while($string = fread($fd,200)){
echo $string;
}
fclose($fd);
}
else { ?>
<form method="post" action="<?PHP echo $PHP_self; ?>" ENCTYPE="multipart/form-data">
file description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>file to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?PHP } ?>
php爱好者站 http://www.phpfans.net Linux|Apache|IIS.
相关阅读 更多 +