<!--#include file="../../../inc/cms_admin.asp" -->
<% 
dim upfolder,parentPath,fileList,json,uptype,upAllowType,echostr
upfolder=getform("upfolder","both")
uptype=getform("uptype","both")
'parentPath=getform("parentPath","both")
select case uptype
	case "image"	: upAllowType=imageExt
	case "file" 	: upAllowType=fileExt
	case "video"	: upAllowType=videoExt
end select

if isnul(upfolder) then 
 parentPath=sitepath&upLoadPath
else
 parentPath=sitepath&upLoadPath&upfolder&"/"
end if

if isfolder(parentPath) then
	echostr="["& endstr(getimgs(parentPath)&getfolderimgs(parentPath),",")&"]"
	echo echostr
end if
function getimgs(selfpath)
	dim filePath,objFiles,objFolder,objFile,jsString
	'on  error resume next   
	filePath=setfolder(selfpath)
	Set objFolder=fso.GetFolder(filePath)
	set objFiles=objFolder.Files
	'循环输出文件夹path下的文件的文件名 
	For each objFile in objFiles 
	  if ifstrin(upAllowType,GetFileExt(objFile.name)) then
		'If GetFileExt(objFile.name)="gif"  or GetFileExt(objFile.name)="jpg" or GetFileExt(objFile.name)="jpeg" or GetFileExt(objFile.name)="png" or GetFileExt(objFile.name)="bmp" Then 
		'getimgs=getimgs& selfpath&objFile.name&"|"
		Set json = jsObject()
		json("date") = objFile.DateLastModified 
		 json("url") = selfpath&objFile.name
		 json("ext") = getfileext(objFile.name)
   		 json("name") = GetFileName(objFile.name)
   		 json("size") =  formatSize(objFile.size )		 
		 jsString=jsString&  json.jsString()&","
	  End  If 
	getimgs=jsString
	Next
end function

function getfolderimgs(cDir)
	'On Error Resume Next
	  dim filePath,objFolder,objSubFolder,objSubFolders,i,imgs
	  i=0
	  'redim  folderList(0)
	  filePath=setfolder(cDir)
	 ' echop filePath
	  set objFolder=fso.GetFolder(filePath)
	  set objSubFolders=objFolder.Subfolders
	  for each objSubFolder in objSubFolders
		  ReDim Preserve folderList(i)
		  With objSubFolder
			 'echo cDir&.name
			 imgs=imgs& getimgs(cDir&.name&"/")
		  End With
		  i=i + 1 
	  next 
	  getfolderimgs=imgs
	  set objFolder=nothing
	  set objSubFolders=nothing
	  'getFolderList=folderList
end function
%>
