顯示具有 FileSystemObject 標籤的文章。 顯示所有文章
顯示具有 FileSystemObject 標籤的文章。 顯示所有文章

2015年5月14日 星期四

上傳檔案,錯誤 'ASP 0104 : 80004005' 上傳下載檔案大小限制設定


在執行上傳檔案時,出現錯誤訊息,如下

錯誤訊息:
要求物件 錯誤 'ASP 0104 : 80004005'
不允許的操作


其實是因為iis 有上傳檔大小限制,以我 IIS7.5 為例,(後面補充IIS6的做法),開啟 iis後,

==============================================
 IIS7.5 上傳下載檔案大小限制設定

  1. 點開ASP
  2. 調整 "要求實體的上限" byte值










完畢。

==============================================
IIS 6 上傳下載檔案大小限制設定

1.視需求勾選
啟用直接 metabase 編輯。允許您在IIS執行時,編輯IIS Metabase設定檔。



2.
開啟 C:\WINDOWS\system32\inetsrv\metabase.xml
AspBufferingLimit="4194304"                     \\下載限制
AspMaxRequestEntityAllowed="204800"   \\上傳限制

把上傳限制設大一點。

重啟IIS

完畢。

==============================================

參考:
win2003 解除iis6.0上傳容量限制
http://pecoju.pixnet.net/blog/post/18548676-win2003-%E8%A7%A3%E9%99%A4iis6.0%E4%B8%8A%E5%82%B3%E5%AE%B9%E9%87%8F%E9%99%90%E5%88%B6-

檔案重新命名


檔案重新命名,用搬移檔案的方式達成。

Syntax

FileSystemObject.MoveFile source,destination

<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
fs.MoveFile "c:\web\*.gif","c:\images\"
set fs=nothing
%>



======================================
參考 :
w3c, The FileSystemObject Object
http://www.w3schools.com/asp/asp_ref_filesystem.asp

2015年2月8日 星期日

檔案與資料夾,建立、刪除




Set fs=Server.CreateObject("Scripting.FileSystemObject")

'來源檔案存在  ---開始---
if fs.FileExists(Src_fName) then

'建立目的資料夾,如果沒有此資料夾,則建立資料夾。
ary_folder = Split(fPath,"\")
Des_fPath = "D:\APfileBK"
Des_fName = Des_fPath & "\" & fName


For i = 0 to UBound(ary_folder)-1
Des_fPath = Des_fPath & "\" & ary_folder(i)
IF not fs.FolderExists(Des_fPath) then
'Response.Write("<br>Des_fPath : " & Des_fPath)
fs.CreateFolder(Des_fPath)
End if
Next


'刪除 '@20141015 檔案有存在,先刪除
if fs.FileExists(Des_fName) then
  'response.write("<br>Des_fName File exists! " &  Des_fName)
'Flag(true or false):預設值為false,true表可以刪除唯讀屬性 設定的檔案,若不設為 true,則遇到唯讀屬性檔案時將產 生『沒有使用權限』的錯誤 (err.number=70)
   
fileOpen.close '關閉檔  
fs.Deletefile Des_fName,true  '刪除檔案 先關閉,才能刪除
end if



'搬移
fs.CopyFile Src_fName,Des_fPath & "\" ,true 'overwrite(是否覆蓋):預設值為true




#####################################################

#T=============================
#T=FSO相關操作
#T= 判斷目錄是否存在
<%
Function IsFloderExist(strFolderName)
    SET FSO=Server.CreateObject("Scripting.FileSystemObject")
    IF(FSO.FolderExists(strFolderName))THEN
        IsFloderExist = True
    ELSE
        IsFloderExist = False
    END IF
    SET FSO=NOTHING
End Function
%>

#T= 創建目錄
<%
Function CreateFolder(strFolderName)
    SET FSO=Server.CreateObject("Scripting.FileSystemObject")
    IF(FSO.FolderExists(strFolderName) = False)THEN
        FSO.CreateFolder(strFolderName)
    END IF
    SET FSO=NOTHING
END Function
%>

#T= 刪除目錄
<%
Function DeleteFolder(strFolderName)
    SET FSO=Server.CreateObject("Scripting.FileSystemObject")
    IF(FSO.FolderExists(strFolderName))THEN
        FSO.DeleteFolder(strFolderName)
    END IF
    SET FSO=NOTHING
END Function
%>

#T= 判斷文件是否存在
<%
Function IsFileExist(strFileName) 
    SET FSO=Server.CreateObject("Scripting.FileSystemObject")
    IF(FSO.FileExists(strFileName))THEN
        IsFileExist = True
    ELSE
        IsFileExist = False
    END IF
    SET FSO=NOTHING
End Function
%>

#T= 刪除文件
<%
Function DeleteFile(strFileName)
    SET FSO=Server.CreateObject("Scripting.FileSystemObject")
    IF(FSO.FileExists(strFileName))THEN
        FSO.DeleteFile(strFileName)
    END IF
    SET FSO=NOTHING
END Function
%>