先上解释代码,后面跟上实用inc代码及调用方法 以上代码只为解释可能有错,实用代码如下:
以下为调用页面:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.CodePage=65001Response.CodePage=65001Response.Charset = "UTF-8"%><!-- #include file="upload.inc" --><%set nowupload=new uploadset file=nowupload.file("file1")if file.fileSize>0 and file.filesize<1000000 then ''获取inPut里面的文件名filename=nowupload.inputval filenameend=file.filename filenameend=split(filenameend,".") if filenameend(1)="gif" or filenameend(1)="jpg" then filename1=split(filename,".")(0)&"."&filenameend(1) file.saveAs Server.mappath(filename1)''''''somecodes''''''
%>
实现方法:
1在需要上传图片的地方插入一个iframe
<iframe id="addgoodsframe" frameborder="0" scrolling="auto" style="float:left; border:0px dotted #f00; width:196px; height:296px; position:absolute; padding:0px;" src="uploadpic_frame.asp?filename=abc">
</iframe>2在uploadpic_frame.asp里面插入form 如:
3在uploadmodpic.asp页面应用inc
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%Session.CodePage=65001Response.CodePage=65001Response.Charset = "UTF-8"%> <%set nowupload=new uploadset file=nowupload.file("file1")if file.fileSize>0 and file.filesize<1000000 then ''获得input里面的文件名filename=nowupload.inputval filenameend=file.filename filenameend=split(filenameend,".") if filenameend(1)="gif" or filenameend(1)="jpg" then filename1=split(filename,".")(0)&"."&filenameend(1) file.saveAs Server.mappath(filename1)''''''somecodes连接数据库等''''''%>