<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include FILE="upload_5xsoft.asp"-->
<!--#include FILE="checklogin.asp"-->
<%Server.ScriptTimeOut=999999%>
<%
Function MakeFileName()
	Dim fname,i
	fname = now()
	fname = replace(fname,"-","")
	fname = replace(fname," ","")
	fname = replace(fname,":","")
	fname = replace(fname,"PM","")
	fname = replace(fname,"AM","")
	fname = replace(fname,"上午","")
	fname = replace(fname,"下午","")
	for i = 1 to 8
	randomize()
		fname = fname & Int(9 * Rnd + 0)
	next
	MakeFileName = fname
End Function 
  
function getex(filename)
	getex = Split(filename,".")(UBound(Split(filename,".")))
End Function

function chan_data(shijian)
	s_year=year(shijian)
	if len(s_year)=2 then s_year="20"&s_year
	s_month=month(shijian)
	if s_month<10 then s_month="0"&s_month
	s_day=day(shijian)
	if s_day<10 then s_day="0"&s_day
	s_hour=hour(shijian)
	chan_data =s_year & s_month 
	
end function
'===================================================================
'                           时间转换函数3
'===================================================================
function chan_day(shijian)		
	s_day=day(shijian)	
	chan_day=s_day 	
end function

function MkDir(p)
	dim fs
	Set fs=Server.CreateObject("Scripting.FileSystemObject")
	If (fs.FolderExists(p)) Then		'目录是否存在
	Else
		fs.CreateFolder(p)		'创建目录
	End If
	set fs=nothing
end function

Function ShowSize(objsize)
	dim sizeExt
	if objsize<1024 then 		   
		 ShowSize=objsize&"byte"
	end if
	if objsize>1024 then
		 objsize=(objsize/1024)
		 ShowSize=formatnumber(objsize,2) & "K"	
	end if
	if objsize>1024 then
		 objsize=(objsize/1024)
		 ShowSize=formatnumber(objsize,2) & "M"		
	end if
	if objsize>1024 then
		 objsize=(objsize/1024)
		 ShowSize=formatnumber(objsize,2) & "G"	   
	end if   
	'ShowSize="<font face=verdana>" & ShowSize & "</font>"		
end Function
	
''''''''''''''''''''''''''''
'start
''''''''''''''''''''''''''''
set upload=new upload_5xsoft
filename=MakeFileName()
'目录处理
current_M=chan_data(now())
current_D=chan_day(now())
folder_mon=server.mappath("/pic/"&current_M)
folder_day=server.mappath("/pic/"&current_M&"/"&current_D)  '今天的目录
call MkDir(folder_mon)
call MkDir(folder_day)
set file=upload.file("Filedata")
theFileName = file.FileName
upfileext = getex(theFileName)
SaveFilePath="/pic/"&current_M&"/"&current_D&"/"& filename & "." & upfileext
DiskFilePath = folder_day &"\"& filename & "." & upfileext
file.SaveAs DiskFilePath
set file=nothing
set upload=nothing
response.Write SaveFilePath
%> 