download file

Just starting out? Need help? Post your questions and find answers here.
hcman
New User
New User
Posts: 2
Joined: Sun Jun 13, 2021 6:50 am

download file

Post by hcman »

i want download file from our server

url example http://xxx.xxxx.xx/posdoc_download.php? ... code=40385

when i try in browser, it returns pdf file... i have no idea how to do it in purebasic :)

many thanks
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: download file

Post by STARGÅTE »

PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
hcman
New User
New User
Posts: 2
Joined: Sun Jun 13, 2021 6:50 am

Re: download file

Post by hcman »

receivehttpfile not work, i set url to my with parameters, but what with file name, i want filename which our server returns... instead of pdf, there is error html page in downloaded file

runprogram maybe ok, but it need external program ... can make problems...
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: download file

Post by infratec »

What's with this:

Code: Select all

InitNetwork()

HttpRequest = HTTPRequest(#PB_HTTP_Get, "http://xxx.xxxx.xx/posdoc_download.php?card=4322&auth=code&authcode=40385")
If HttpRequest
  Debug "Statuscode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "Header: " + HTTPInfo(HTTPRequest, #PB_HTTP_Headers)
  
  *Response = HTTPMemory(HTTPRequest)
  
  FinishHTTP(HTTPRequest)
  
  If *Response
    Debug "Response size: " + MemorySize(*Response)
    ShowMemoryViewer(*Response, MemorySize(*Response))
    FreeMemory(*Response)
  EndIf
  
Else
  Debug "Request creation failed"
EndIf
Post Reply