日期:2014-05-17  浏览次数:20871 次

如何获得<iframe>中文件上传图片后图片的大小和路径?
用风声无组件2.11来上传文件,目前已经能通过它自带的功能获得上传文件的大小和上传后的保存路径,以前是在信息提交页a.asp中通过 <a   href= "javascript:; "   onClick= "javascript:open_win( 'Img_upload.asp?UpStyle=AddImg ', 'contact ',463,380, 'no '); "> 上传图片 </a> 这样来弹出一个新页面img_upload.asp,在这个页中用
<table   width= "100% "     border= "0 "   cellspacing= "1 "   cellpadding= "0 "   style= "background-color:#F0F0F0; ">
<form   name= "form111 "   enctype= "multipart/form-data "   method= "post "   action= "Upload_Save.asp?UpStyle=AddProductImg ">
                        <tr>
                    <td   width= "84% "   class= "tdbg "> 大图:
                        <input   name= "strPhoto2 "   type= "file "   id= "strPhoto2 ">  
                        (不能超过1024K即1M) <br> 小图:
                        <input   name= "strPhoto1 "   type= "file "   id= "strPhoto1 "> (不能超过150K)   <input   type= "submit "   name= "Submit "   value= "上   传 "   class= "button01-out "> </td>
                </tr>
</form> </table>
来实现上传文件,在Upload_Save.asp中获得文件的上传后保存路径以及上传文件的大小,通过
<script   language= "Javascript ">
function   ShowUrl(BigUrl,SmallUrl,Imgsize)
{
window.opener.document.form1.BigImg.value=BigUrl;
window.opener.document.form1.SmallImg.value=SmallUrl;
window.opener.document.form1.Imgsize.value=Imgsize;

}
</script>
<%
dim   request2  
'建立上传对象
set   request2=New   UpLoadClass
'设置为手动保存模式
request2.AutoSave=2
Request2.FileType= "gif/jpg/jpeg/bmp "

'设置服务器文件保存路径
Request2.SavePath= "../UploadFiles/ "
'打开对象
request2.open()
%>
<table   width= "100% "     border= "0 "   cellspacing= "1 "   cellpadding= "0 "   style= "background-color:#F0F0F0; ">
<tr>  
<td>
<%
request2.MaxSize=1024000
if   request2.Save( "strPhoto2 ",0)   then
Dim   BigUrl
BigUrl=request2.SavePath&request2.Form( "strPhoto2 ")
response.Write( " <br> 产品大图: "&BigUrl)
If   Left(BigUrl,3)= "../ "   Then   BigUrl=Right(BigUrl,Len(BigUrl)-2)
end   if
Dim   Imgsize,tempsize
Imgsize=request2.form( "strPhoto2_size ")/1024
Imgsize=formatnumber(Imgsize)
tempsize=Imgsize& "kb "
response.Write( " <br> 大图尺寸: "&tempsize)
%>
<script   language= "Javascript ">
ShowUrl( ' <%=BigUrl%> ', ' <%=SmallUrl%> ', ' <%=Imgsize%> ')
</script>
</td>
</tr>
</table>
来获得保存路径和大小,并且使这两个值自动显示在a.asp中表单项BigImg和Imgsize中

现在我想用 <i