sending a file to a webpage (.gambas cgi)
Posted
#1
(In Topic #1266)
Banned
I want in my gambas application to be able to open a URL to a gambas cgi (gb.web) and post a file to it.
So on the computer side is a gambas program that wants to send file data.
And on the server end it receives the file data so it can then save it as a file.
The program and the online server are mine so I am free to do this another way if there is a better way.
It is for my Blockski+ program , I am making a Highscore repository/server so players can easily merge scoreboards.
I currently have it so i can HttpClient.Download() a .gambas cgi with various parameters so my program can simply download urls like
web.address/cgi-bin/Scores.gambas?getusers
web.address/cgi-bin/Scores.gambas?getscores=username
getusers just prints available users and getscores prints the users scores.
this is easy , the .gambas cgi just prints text so the result of the download it the text i want.
But how to reverse this so i can send a whole file.
I've tried httpClient.Post() but cannot get it to work.
I could do with an example of how to post data using httpClient.class
Cheers in advance for any tips
Posted
Administrator

Maybe you can upload the file by FTP, and then move it to the proper location?
Posted
Banned
So I Cannot really add my ftp login details to the app.
Needs to be sent by http push or post I think
Posted
Regular

Then you can write the stuff in your page to upload to that location via ftp. I think Gambas can handle that.
Now getting stuff out of there is a different kettle of fish.
(Caveat) It is about 10 or so years since I was doing that stuff.
hth
b
p.s. IIRC http is not for transferring files, just a bunch of text with a bunch of markup tags. Post is just the same and I've not heard of push but I'd guess ditto. ftp is OTOH for transferring files, maybe that's why they called it that.
p.p.s. Maybe wade through the jcrap on a site like https://www.flaticon.com/ to see how they download files to the user pc,
p.p.p.s. <COLOR color="#BF40BF">I sit corrected</COLOR>. Maybe POST a File via HTTP Request | The Ultimate Guide | by API4AI | Medium could help
Posted
Banned
multipart/form-data looks promising
But what i don't know is how to process the request server-side
Here is what my program does to send the data
the URL looks something like
127.0.0.1/cgi-bin/Scoreprog.gambas?submit
I can detect the "submit" in the QUERY_STRING server-side but then i do not know how to find the data sent? it does not seem to be in any CGI[Key] variable.
the client-side shows bytes are sent but how do i find the data server-side?
Cheers
Posted
Administrator



So what you are asking is, where is the file on the server or what?
I see: As server side can detect the submit, you know on server side that upload happened.
Now you want to go to the file from server side I presume, to do some stuff.
My guess is that the web server configuration determines the upload location and access rights to upload to there
And I guess your upload on client side determines the filename.
These are just some wild guesses that might set you on the right path (or not).
Haven' t used it myself, did use the opposite, downloading from server.
gbWilly
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Banned
(who'd have thought that to process the request of posted data i had to use Request.Post :roll: )
The solution was the following….
Set
Request.Debug = True
send data with content type multipart/form-data
then server-side i can simply use
Easy as that
EDIT:
actually I found that way truncated data.
The following way worked much better and there is no need to set Request.Debug = True when doing it like this
1 guest and 0 members have just viewed this.


