%
function TestEnvironment()
Dim fso, fileName, testFile, streamTest
TestEnvironment = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(uploadsDirVar) then
TestEnvironment = "Folder " & uploadsDirVar & " does not exist.
The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
fileName = uploadsDirVar & "\test.txt"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
If Err.Number<>0 then
TestEnvironment = "Folder " & uploadsDirVar & " does not have write permissions.
The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
Err.Clear
testFile.Close
fso.DeleteFile(fileName)
If Err.Number<>0 then
TestEnvironment = "Folder " & uploadsDirVar & " does not have delete permissions, although it does have write permissions.
Change the permissions for IUSR_computername on this folder."
exit function
end if
Err.Clear
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
TestEnvironment = "The ADODB object Stream is not available in your server.
Check the Requirements page for information about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
Dim Upload, fileName, fileSize, ks, i, fileKey,diagnostics
uploadsDirVar = "D:\Web_apps\E-Market\ESHOP\UPLOAD"
Set Upload = New FreeASPUpload
TargetURL = Upload.Form("TargetURL")
diagnostics = TestEnvironment()
if diagnostics<>"" then
response.write diagnostics
response.write "
After you correct this problem, reload the page."
end if
Upload.Save(uploadsDirVar)
'If err.number<>0 Then
' Response.Write "ERR DESC : " & Err.Description
'end if
SaveFiles = ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
SaveFiles = "檔案上傳成功: "
for each fileKey in Upload.UploadedFiles.keys
FileName=Upload.UploadedFiles(fileKey).FileName
FileSize=Upload.UploadedFiles(fileKey).Length
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
next
else
SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
end if
'response.write SaveFiles&"
"
picname = Upload.form("picname")
SET fs = Server.CreateObject("Scripting.FileSystemObject")
if Upload.Form("Type")="1" then
dir="\cat\banner\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="2" then
dir="\self\images\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="3" then
dir="\self\docs\"
ftype=""
FileNanme1=FileName
end if
if Upload.Form("Type")="4" then
dir="\ad\banner\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="5" then
dir="\prod\banner\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="6" then
dir="\news\banner\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="7" then
dir="\doc\banner\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")="8" then
dir="\prod\banner\"&picname&"\"
ftype=".gif"
FileNanme1=""
end if
if Upload.Form("Type")<>"1" and Upload.Form("Type")<>"2" and Upload.Form("Type")<>"3" and Upload.Form("Type")<>"4" and Upload.Form("Type")<>"5" and Upload.Form("Type")<>"6" and Upload.Form("Type")<>"7" and Upload.Form("Type")<>"8" then
dir="\images\"
ftype=".gif"
FileNanme1=""
end if
'若目標目錄不存在則建立目錄
if fs.FolderExists (session("front_dir") & session("virtualdir") & dir )=false then
'response.write session("front_dir") & session("virtualdir") & dir&"
"
Set f = fs.CreateFolder(""&session("front_dir") & session("virtualdir") & dir)
'response.write "111
"
end if
'*************Copy File from upload to banner************
IF (fs.FileExists(session("front_dir") & session("virtualdir") & "\upload\" & FileName)) then
fs.CopyFile session("front_dir") & session("virtualdir") & "\upload\" &FileName, session("front_dir") & session("virtualdir") & dir & picname & ftype & FileNanme1
End If
'*************Delete File in upload***************
IF (fs.FileExists(session("front_dir") & session("virtualdir") & "\upload\" & FileName)) then
fs.DeleteFile(session("front_dir") & session("virtualdir") & "\upload\" & FileName)
End If
if err.number<>0 Then
Response.Write "
| "
Response.Write "上傳圖檔:" & FileName & ""
Response.Write " Size: " & FileSize & " bytes 失敗!!不允許上傳中文檔名!! |
"
Response.Write " |
"
else
if Upload.Form("Type")="3" then
if LCase(right(FileName,3))="xls" then
picname1="Excelicon"
end if
if LCase(right(FileName,3))="doc" then
picname1="Wordicon"
end if
if LCase(right(FileName,3))="prj" then
picname1="Projecticon"
end if
if LCase(right(FileName,3))="vsd" then
picname1="Visioicon"
end if
if LCase(right(FileName,3))="mdb" then
picname1="Accessicon"
end if
if LCase(right(FileName,3))="ppt" then
picname1="PowerPointicon"
end if
Response.Write "| "
Response.Write "上傳檔案:" & FileName & ""
Response.Write " Size: " & FileSize & " bytes 成功!! |
"
Response.Write " |
"
else
Response.Write "| "
Response.Write "上傳圖檔:" & FileName & ""
Response.Write " Size: " & FileSize & " bytes 成功!! |
"
Response.Write " |
"
end if
end if
SET fs=nothing
Set Upload=nothing
%>