%
dim strLang
'if a languag var was submitted then...
If Request.QueryString("lang") <> "" Then
If InStr(Request.QueryString("lang"), "_") Then
strLang = Request.QueryString("lang")
Else
strLang = "_" & Request.QueryString("lang")
End If
End If
if Request.QueryString("action")="del" then
filepath = request.QueryString("file")
Set objFSO1 = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = objFSO1.GetFile(Server.MapPath(filepath))
MyFile.Delete
Response.Redirect "default_Image.asp?catid="& request.QueryString("catid")
end if
if Request.QueryString("action")="upload" then
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
ByteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin
Dim aux, aux1, FILEFLAG
Dim ImageCateg, ContentType, FilePathName, FileName, Value
ImageCateg=UploadRequest.Item("inpcatid").Item("Value")'Image Folder
on error resume next
ContentType =UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0
if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if
if FileName<>"" then
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
MyFile.Write getString(value)
MyFile.Close
end if
set UploadRequest = nothing
Response.Redirect "default_Image.asp?catid="&ImageCateg
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
Insert/Update Image
<%
dim objFSO
dim objMainFolder
dim strOptions
dim strHTML
dim catid
strHTML = ""
set objFSO = server.CreateObject ("Scripting.FileSystemObject")
set objMainFolder = objFSO.GetFolder(server.MapPath(imgFolder))
catid = CStr(request("catid"))'bisa form, bisa querystring
if catid="" then catid = objMainFolder.path
dim objTempFSO
dim objTempFolder
dim objTempFiles
dim objTempFile
set objTempFSO = server.CreateObject ("Scripting.FileSystemObject")
set objTempFolder = objTempFSO.GetFolder (catid)
set objTempFiles = objTempFolder.files
strHTML = strHTML & "
"
for each objTempFile in objTempFiles
'***********
'objTempFile.path => image physical path
'basePath => base path
set basePath = objFSO.GetFolder(server.MapPath(imgFolder))
PhysicalPathWithoutBase = Replace(objTempFile.path,basePath.path,"")
sTmp = replace(PhysicalPathWithoutBase,"\","/")'fix from physical to virtual
sCurrImgPath = imgFolder & sTmp
'***********
strHTML = strHTML & "
"
strHTML = strHTML & "
" & objTempFile.name & "
"
'strHTML = strHTML & "
" & objTempFile.type & "
"
strHTML = strHTML & "
" & FormatNumber(objTempFile.size/1000,0) & " kb
"
strHTML = strHTML & "
select
"
strHTML = strHTML & "
del
"
next
strHTML = strHTML & "
"
Function createCategoryOptions(pi_objFolder)
dim objFolder
dim objFolders
dim intFolderCounter
set objFolders = pi_objfolder.SubFolders
for each objFolder in objFolders
'Recursive programming starts here
createCategoryOptions objFolder
next
if pi_objFolder.attributes and 2 then
'hidden folder then do nothing
else
'***********
set basePath = objFSO.GetFolder(server.MapPath(imgFolder))
'response.Write catid & " - " & oo.path
Response.Write Replace(pi_objFolder.path,basePath.path,"")
'***********
if CStr(catid)=CStr(pi_objFolder.path) then
strOptions = strOptions & "" & vbCrLf
else
strOptions = strOptions & "" & vbCrLf
end if
end if
strOptions = strOptions & vbCrLf
createCategoryOptions = strOptions
End Function
function ConstructPath(str)
str = mid(str,len(server.MapPath ("./"))+1)
ConstructPath = replace(str,"\","/")
end function
%>