<!--#include file="../conn/conn2.asp" -->
<!--#include file="../conn/function.asp" -->
<!--#include file="AienUpload/upload_Class.asp"-->
<%
 on error resume next
 Server.ScriptTimeout = 9999999
 Dim Upload,successful,thisFile,allFiles,upPath,path
 set Upload=new AnUpLoad
 Upload.openProcesser=true  '打开进度条显示
 Upload.SingleSize=clng(500 * 1024)*1024  '设置单个文件最大上传限制,按字节计；默认为不限制，本例为512M
 Upload.MaxSize=clng(500 * 1024)*1024 '设置最大上传限制,按字节计；默认为不限制，本例为1G
 Upload.Exe="jpg|png|gif|flv|mp3|doc|rar|ppt|pdf"  '设置允许上传的扩展名
 Upload.GetData()
 if Upload.ErrorID>0 then
 	upload.setApp "faild",1,0 ,Upload.description
 else
 	if Upload.files(-1).count>0 then
		dim str
		for each file in Upload.files(-1)
 	        upPath=request.querystring("path")
			P_width=request.querystring("P_width")
			P_height=request.querystring("P_height")
    		path=server.mappath(upPath)
    		set tempCls=Upload.files(file) 
            upload.setApp "saving",Upload.TotalSize,Upload.TotalSize,tempCls.FileName
    		successful=tempCls.SaveToFile(path,0)
'*******************************************************************************************

if right(tempCls.FileName,3)="jpg" and C_cut=1 then
on error resume Next	 
Server.CreateObject("Persits.Jpeg")	 
if err=0 then 		
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("../media/"&tempCls.FileName)
Jpeg.Open Path
Jpeg.Interpolation=0
Jpeg.Quality=100
P_Jwidth=Jpeg.OriginalWidth
P_Jheight=Jpeg.OriginalHeight


if P_width<>"" and P_height<>""  then
if P_Jwidth<>P_width or P_Jheight<>P_height then
if Jpeg.OriginalHeight/P_height > Jpeg.OriginalWidth/P_width then
Jpeg.Width =  P_width
Jpeg.Height = Jpeg.OriginalHeight*P_width/Jpeg.OriginalWidth 
Jpeg.crop 0,Jpeg.Height/2-P_height/2,P_width,Jpeg.Height/2+P_height/2
else
Jpeg.Height = P_height
Jpeg.Width = Jpeg.OriginalWidth*P_height/Jpeg.OriginalHeight
Jpeg.crop Jpeg.Width/2-P_width/2,0,Jpeg.Width/2+P_width/2,P_height
end if
end if
end if


Jpeg.Save Server.MapPath("../media/_"&P_Jwidth&"_"&P_Jheight&"_"&tempCls.FileName)
S_name="media/_"&P_Jwidth&"_"&P_Jheight&"_"&tempCls.FileName
Jpeg.Close:Set Jpeg = Nothing	
end if
else

if right(tempCls.FileName,3)="jpg" then
Set PP = New ImgWHInfo   
W = PP.imgW(Server.Mappath("../media/"&tempCls.FileName))   
H = PP.imgH(Server.Mappath("../media/"&tempCls.FileName))  
Set pp = Nothing 
S_name="media/_"&W&"_"&H&"_"&tempCls.FileName

Set fs=Server.CreateObject("Scripting.FileSystemObject")
oldpath=server.mappath("../media/"&tempCls.FileName)
newpath=server.mappath("../media/_"&W&"_"&H&"_"&tempCls.FileName)
fs.CopyFile oldpath,newpath
set fs=nothing
end if
end if

if S_name="" then
S_name=tempCls.FileName
end if
'******************************************************************************************
			thisFile="{name:'"&S_name&"',size:" & tempCls.Size & "}"
			allFiles=allFiles & thisFile & ","
    		set tempCls=nothing			
		next
		upload.setApp "saved",Upload.TotalSize,Upload.TotalSize,mid(allFiles,1,len(allFiles)-1)
    else
        upload.setApp "faild",1,0,"没有上传任何文件"
 	end if
 end if
 if err then upload.setApp "faild",1,0,err.description
 set Upload=nothing
%>
