This topic is locked

Rename File Upload

11/22/2013 6:38:12 PM
ASPRunnerPro General questions
lefty author

I tried the script from the manual to change physical file name in Asprunner 8.0 build 19042 . I am not getting any error but the filename in the folder does not change . In the database I see the data for photo_upload field is just [] . I do have thumbnails set to generate which I will script later but not sure if that is the problem. Can I use old script from 6.3 here? Or can someone see problem script below. Thanks ...
' get information about uploaded files
if bValue(values("photo_upload")) then
set fileArray = CreateDictionary()
set fileArray = my_json_decode(values("photo_upload"))
Set objFSO = CreateObject("Scripting.FileSystemObject")
' rename files
for i = 0 to aspcount(fileArray)-1
fileName = fileArray(i)("name")
newFileName = "../Photos/" & values("fldbrand") & "
" & values("merchname") & "" & values("merchid")& "" & FormatDateTime(values("flddate"),2) & i & ".jpg"
sPath = left(getabspath(fileName),len(getabspath(fileName))-len(fileName))
objFSO.MoveFile getabspath(fileName) , sPath & newFileName
fileArray(i)("name") = newFileName
next
end if
' update values of the field that stores file names
values("photo_upload") = my_json_encode(fileArray)

admin 11/23/2013

Not seeing anything wrong. My guess is that you need to output newFileName value right after it's calculated to see if path to the file is correct. Not sure what else to suggest.