ckfinder ASP版上传文件按日期生成目录(文件夹)
Ckeditor整合Ckfinder ASP版本后,上传文件全部自动保存到images文件夹中,多了后管理不方便,可以把文件图片按照日期生成目录子文件夹,然后把图片存入子文件夹中。
打开文件ckfinder\core\connector\asp\CommandHandler\FileUpload.asp
大概59行:function sendResponse( response )后面改成:
set oRegistry = oCKFinder_Factory.Registry
oRegistry.Item("FileUpload_fileName") = "unknown file"
If request.queryString("command") = "QuickUpload" Then
Dim ymDir
ymDir = Year(Date()) &"/"& Right("0" & Month(Date()),2)
oRegistry.Item("FileUpload_url") = currentFolder.getUrl() & ymDir & "/"
Else
oRegistry.Item("FileUpload_url") = currentFolder.getUrl()
End If
oRegistry.Item("FileUpload_fileName") = "unknown file"
If request.queryString("command") = "QuickUpload" Then
Dim ymDir
ymDir = Year(Date()) &"/"& Right("0" & Month(Date()),2)
oRegistry.Item("FileUpload_url") = currentFolder.getUrl() & ymDir & "/"
Else
oRegistry.Item("FileUpload_url") = currentFolder.getUrl()
End If
大概140行:iCounter = 0
sServerDir = currentFolder.getServerPath() 后面添加:
If request.queryString("command") = "QuickUpload" Then
Dim ymDir
ymDir = Year(Date()) &"/"& Right("0" & Month(Date()),2)
sServerDir = sServerDir & "/" & ymDir
if (Not oUFS.createDirectoryRecursively(sServerDir)) then
If Err.number<>0 then
errorHandler.throwError CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, "", "Not able to create folder " & sServerDir & " (error:" & Err.number & ", " & Err.description & ") "
End If
errorHandler.throwError CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, "", "Not able to create folder " & sServerDir
End If
End If
Dim ymDir
ymDir = Year(Date()) &"/"& Right("0" & Month(Date()),2)
sServerDir = sServerDir & "/" & ymDir
if (Not oUFS.createDirectoryRecursively(sServerDir)) then
If Err.number<>0 then
errorHandler.throwError CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, "", "Not able to create folder " & sServerDir & " (error:" & Err.number & ", " & Err.description & ") "
End If
errorHandler.throwError CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, "", "Not able to create folder " & sServerDir
End If
End If
修改后,上传文件的目录结构看起来是这样的: