Downloading file with different name?
Posted: Mon Jan 05, 2026 11:46 am
Hello,
I would like to download a file and save it to the user with a different name than the one on the server. I'm doing this:
I'm getting this error: RangeError: invalid or out-of-range index (http://127.0.0.1:9080/spiderbasic.js?t=1767612810, line: 149)
What is my mistake? Thanks in advance.
I would like to download a file and save it to the user with a different name than the one on the server. I'm doing this:
Code: Select all
Procedure OnLeftClick_OK()
If( GetGadgetState( #Checkbox_0 ) = #PB_Checkbox_Checked )
;procedure to download moustique
Debug "Downloading book."
If( ReadFile(0, "moustique.pdf", @Callback) )
Length.q = Lof(0)
*Buffer = AllocateMemory(Length);Error here: RangeError: invalid or out-of-range index (http://127.0.0.1:9080/spiderbasic.js?t=1767612810, line: 149)
*Buffer = ExportFileMemory(0)
;ReadData(0, *Buffer, 0, Length)
CreateFile(1, "mosticos.pdf", @Callback)
WriteData(1, *Buffer, 0, Length);There is an error in the documentation for this function. Only 3 parameters are given when 4 are required. Perhaps this should be reported?
ExportFile(1, "application/pdf")
CloseFile(0)
CloseFile(1)
;ExportFile("moustique.pdf", "application/pdf")
EndIf
EndIf
EndProcedure
What is my mistake? Thanks in advance.