|
为了建设班级主页,买了个空间,支持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″>
上传说明:最多可以同时上传五个文件,其中标题最多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>
photo_addphoto.js 代码拷贝框
|