简易电子相册
时间:2007-02-17 来源:PHP爱好者
本程序分为两个PHP页面,一个为send.php(用来上传图片)另一个为get.php(用来接授图片)
send.php
<html>
<head><title>网友图片上传</title></head>
<body>
<h1 align="center">
<font color="#FF0000">网友影集</font>
</h1>
<!--webbot BOT="Generatedscript" PREVIEW=" " startspan --><script Language="Javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.name.value == "")
{
alert("请在 name 域中输入值。");
theForm.name.focus();
return (false);
}
if (theForm.name.value.length <1)
{
alert("在 name 域中,请至少输入 1 个字符。");
theForm.name.focus();
return (false);
}
if (theForm.name.value.length > 20)
{
alert("在 name 域中,请最多输入 20 个字符。");
theForm.name.focus();
return (false);
}
return (true);
}
//--></script><!--webbot BOT="Generatedscript" endspan --><form enctype="multipart/form-data"
method="post" action="http://202.194.139.157/php/get.php" onsubmit="return
FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<table border="1" width="100%" bgcolor="#66CCFF" bordercolorlight="#FFFF00"
bordercolordark="#FFFF00">
<tr>
<td width="31%" align="right" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><b><font
color="#0000FF">请输入您的姓名</font></b></td>
<td width="69%" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><!--webbot
bot="Validation" B-Value-Required="TRUE" I-Minimum-Length="1"
I-Maximum-Length="20" --><input type="text" name="name" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="31%" align="right" bordercolorlight="#FFFF00" bordercolordark="#FFFF00">
<b><font color="#0000FF">
请选择或输入上传文件名:</font></b></td>
<td width="69%" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><input name="upfile"
type="file"><input type="submit" value="上传">
</td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" >
</form>
<p align="center"><b><font color="#FF0000">网友照片列表</font></b></p>
<table border="1" width="100%" bordercolor="#FF99FF">
<tr>
<td width="100%" bgcolor="#66CCFF" bordercolorlight="#FFFFFF"
bordercolordark="#FFFF00">
<?
$fp=fopen("list.txt","r");
$list=fgets($fp,2550000);
echo "$list";
fclose($fp);
?>
</td>
</tr>
</table>
<p align="center">
声名:本影集不支持HTTP方式,请用绝对路径!</br>
请务必使用JPG或GIF图像,否则格删无论!</br>
本影集由孤雪制作维护</br></p>
<p align="center"><b>CopyRight (c) 2000 <a href="http://bill.sdau.edu.cn" target="_blank" style="color:
#000000">孤雪心轩</a></b></p>
<p align="center"> </p>
</body>
</html>
get.php
<?php
if ($upfile_size>=80000) {
echo "请选择小于80000字节的图片!";
} else {
$f="$name.txt";
if (file_exists($f)) {
echo "<center><font
color=’#FF0000’><big><strong>$name"."已存在,请另选一个用户名!</strong></big></font>
";
echo "这是"."$name"."的图片
";
$fp=fopen("$f","r");
$src=fgets($fp,255);
echo "$src</center>";
fclose($fp);
} else {
$check="$upfile_type";
echo "您上传的文件是: $check 类型的
";
if ($check != "image/gif" and $check != "image/pjpeg") {
echo "请选择gif或jpg格式的图片上传!";
} else {
$f="$upfile";
copy ($f,"Inetpubwwwrootuploadf.".$upfile_name);
echo "您上载的文件信息如下:";
echo "原始文件名 : $upfile_name</br>";
echo "文件大小(字节): $upfile_size</br>";
echo "文件类型 : $upfile_type</br>";
echo "<center>这是您上传的图片</center>";
echo "<center><image src=’http://202.194.139.157/upload/f.$upfile_name’></center>";
$src="<image src=’http://202.194.139.157/upload/f.$upfile_name’>";
$fp=fopen("$name.txt","w");
fwrite($fp,$src);
fclose($fp);
$list=fopen("list.txt","a");
$listname="<a href=’http://202.194.139.157/upload/f.$upfile_name’>$name</a>牋牋";
fwrite($list,$listname);
fclose($list);
} //type
} //exists
} //size
?>
php爱好者站 http://www.phpfans.net 网页特效|网页模板
send.php
<html>
<head><title>网友图片上传</title></head>
<body>
<h1 align="center">
<font color="#FF0000">网友影集</font>
</h1>
<!--webbot BOT="Generatedscript" PREVIEW=" " startspan --><script Language="Javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.name.value == "")
{
alert("请在 name 域中输入值。");
theForm.name.focus();
return (false);
}
if (theForm.name.value.length <1)
{
alert("在 name 域中,请至少输入 1 个字符。");
theForm.name.focus();
return (false);
}
if (theForm.name.value.length > 20)
{
alert("在 name 域中,请最多输入 20 个字符。");
theForm.name.focus();
return (false);
}
return (true);
}
//--></script><!--webbot BOT="Generatedscript" endspan --><form enctype="multipart/form-data"
method="post" action="http://202.194.139.157/php/get.php" onsubmit="return
FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<table border="1" width="100%" bgcolor="#66CCFF" bordercolorlight="#FFFF00"
bordercolordark="#FFFF00">
<tr>
<td width="31%" align="right" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><b><font
color="#0000FF">请输入您的姓名</font></b></td>
<td width="69%" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><!--webbot
bot="Validation" B-Value-Required="TRUE" I-Minimum-Length="1"
I-Maximum-Length="20" --><input type="text" name="name" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="31%" align="right" bordercolorlight="#FFFF00" bordercolordark="#FFFF00">
<b><font color="#0000FF">
请选择或输入上传文件名:</font></b></td>
<td width="69%" bordercolorlight="#FFFF00" bordercolordark="#FFFF00"><input name="upfile"
type="file"><input type="submit" value="上传">
</td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" >
</form>
<p align="center"><b><font color="#FF0000">网友照片列表</font></b></p>
<table border="1" width="100%" bordercolor="#FF99FF">
<tr>
<td width="100%" bgcolor="#66CCFF" bordercolorlight="#FFFFFF"
bordercolordark="#FFFF00">
<?
$fp=fopen("list.txt","r");
$list=fgets($fp,2550000);
echo "$list";
fclose($fp);
?>
</td>
</tr>
</table>
<p align="center">
声名:本影集不支持HTTP方式,请用绝对路径!</br>
请务必使用JPG或GIF图像,否则格删无论!</br>
本影集由孤雪制作维护</br></p>
<p align="center"><b>CopyRight (c) 2000 <a href="http://bill.sdau.edu.cn" target="_blank" style="color:
#000000">孤雪心轩</a></b></p>
<p align="center"> </p>
</body>
</html>
get.php
<?php
if ($upfile_size>=80000) {
echo "请选择小于80000字节的图片!";
} else {
$f="$name.txt";
if (file_exists($f)) {
echo "<center><font
color=’#FF0000’><big><strong>$name"."已存在,请另选一个用户名!</strong></big></font>
";
echo "这是"."$name"."的图片
";
$fp=fopen("$f","r");
$src=fgets($fp,255);
echo "$src</center>";
fclose($fp);
} else {
$check="$upfile_type";
echo "您上传的文件是: $check 类型的
";
if ($check != "image/gif" and $check != "image/pjpeg") {
echo "请选择gif或jpg格式的图片上传!";
} else {
$f="$upfile";
copy ($f,"Inetpubwwwrootuploadf.".$upfile_name);
echo "您上载的文件信息如下:";
echo "原始文件名 : $upfile_name</br>";
echo "文件大小(字节): $upfile_size</br>";
echo "文件类型 : $upfile_type</br>";
echo "<center>这是您上传的图片</center>";
echo "<center><image src=’http://202.194.139.157/upload/f.$upfile_name’></center>";
$src="<image src=’http://202.194.139.157/upload/f.$upfile_name’>";
$fp=fopen("$name.txt","w");
fwrite($fp,$src);
fclose($fp);
$list=fopen("list.txt","a");
$listname="<a href=’http://202.194.139.157/upload/f.$upfile_name’>$name</a>牋牋";
fwrite($list,$listname);
fclose($list);
} //type
} //exists
} //size
?>
php爱好者站 http://www.phpfans.net 网页特效|网页模板
相关阅读 更多 +