打印本文 打印本文 关闭窗口 关闭窗口
用 SA FileUp 上传多文件
作者:武汉SEO闵涛  文章来源:敏韬网  点击数743  更新时间:2009/4/23 14:18:40  文章录入:mintao  责任编辑:mintao
为了建设班级主页,买了个空间,支持SA FileUp组件。
鼓弄了一天,终于有了大致的了解,下面是我的实例,希望对大家有所帮助。

大家可以根据自己的实际情况进行修改,特别是数据库操作部分。
============================================
利用稻香老农的无组件进行多文件上传
请见:
www.blueidea.com/bbs/newsdetail.asp?id=1249535&posts=current
==================================================
本例属于文件和表单项的混合提交。

简单说明:
虽然重点在处理页上,但我觉得有必要介绍一下表单的项目。
本例是相册里像片的上传。
其中的groupID是隐藏域传递的大类的ID
其中的albumID是隐藏域传递的小类的ID
file1-->>file5是文件
photoTitle1-->>photoTitle5 是像片的标题
photoIntro1-->>photoIntro5 是像片的简介
photoWidth1-->>photoWidth5 是像片的宽度
photoHeight1-->>photoHeigth5 是像片的高度
photoSize1-->>photoSize5 是像片的大小。

注意:因本人没有声明变量的习惯,所以大家要是强制声明变量的话,就得自己加了。
===========================================

提交页:主要代码如下
<form name="fileForm" method="post" action="photo_savephoto.asp" enctype="multipart/form-data" onSubmit="return checkForm();">

<INPUT name="groupID" type="hidden" id="groupID"
         value="<%=groupID%>" size="10">
<INPUT name="albumID" type="hidden" id="albumID"
         value="<%=albumID%>" size="10">

&nbsp;&nbsp;上传说明:最多可以同时上传五个文件,其中标题最多30字,简介200字。
<table width="96%" align="center" cellpadding="4" cellspacing="2">
<tr align="center" valign="middle">
<td align="left" bgcolor="#F4CECE" id="upid">文件1</td>
<td height="29" align="left" bgcolor="#F4CECE" id="upid">
<INPUT name="file1" type="file" class="myInput" size="20">
宽: <INPUT name="photoWidth1" type="text" class="input-disabled" id="photoWidth1" size="5" readonly="">
高: <INPUT name="photoHeight1" type="text" class="input-disabled" id="photoHeight1" size="5" readonly="">
大小:<INPUT name="fileSize1" type="text" class="input-disabled" id="fileSize1" size="5" readonly="">
</td>
</tr>
<tr align="center" valign="middle">
<td colspan="2" align="left" bgcolor="#FDF2F2" id="upid">
标题: <INPUT name="photoTitle1" type="text" class="myInput" id="photoTitle1" size="40">
<BR>
简介:<TEXTAREA name="photoIntro1" cols="60" rows="5" class="myInput" id="photoIntro1"></TEXTAREA>
</td>
</tr>

。。。。。。。

<tr align="center" valign="middle" bgcolor="#F4CECE">
<td height="24" colspan="2">
<input name="Submit" type="submit" class="myButton" value="开始上传">
<input name="Submit2" type="reset" class="myButton" value="重新填写">
</td>
</tr>
</table>
</form>


下面的script是我用来检查图片属性的。其中检查了图片的宽度,高度,大小,是否是图片。
<SCRIPT language="JavaScript">
<!--
    var upFileSize=<%=upFileSize%>;
//-->
</SCRIPT>

<SCRIPT language="JavaScript" src="photo_addphoto.js"></SCRIPT>

<TABLE width="98%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
<TR>
<TD height="1"><img src="images/add.gif" id="loadPhoto" onload="if(!firstLoad)showInfo();"></TD>
</TR>
</TABLE>

打印本文 打印本文 关闭窗口 关闭窗口