Hi Henrik,
I am since yesterday working on the same issue, namely file upload. There is an
example on how to do that in forms.adb which can be found in the demo
directory. The application forms.adb demonstrates traditional post requests to
the server forcing a full reload of the web page. But the example code there is
good to get started.
I have been experimenting with making AJAX request to the server by using the
following approach (hopefully the code is inspirational, I would prefer sending
a complete code example of forms.adb with the file upload without complete page
refresh but it is more than a thousand lines of code and not suitable for
e-mail):
Gnoga.Server.Connection.Execute_Script
(ID => Main_Window.Connection_ID,
Script =>
"var uploadRequest = new XMLHttpRequest();" &
"uploadRequest.open('post', window.location.href +
'demo');" &
"var file = document.getElementById('" &
Upload_File_Input.ID & "').files[0];" &
"var fd = new FormData();" &
"fd.append(""fn"", file);" &
"uploadRequest.send(fd);");
However, trigggering file upload using XMLHttpRequest causes the uploaded file
to be corrupted or bytes are missing in the resulting uploaded file. Hopefully
somebody in the Gnoga mailing list has been more successful. Currently I do
recommend uploading a file with complete page refresh as in forms.adb because
it works.
Best regards,
Joakim
________________________________
Från: Henrik Härkönen <[email protected]>
Skickat: den 1 oktober 2019 09:54
Till: Gnoga support list
Ämne: [Gnoga-list] File upload
Hello!
I'm not very experienced yet with Gnoga (or with Ada for that matter), but I
was planning to make this little tool for the choir I'm singing in, which would
involve the user to send a PDF files to the app and then it would do "things"
with it and return some result file.
How would one go about adding a file upload functionality with Gnoga? I browsed
briefly through the API, but nothing related to it was caught by my eye.
Best regards,
Henrik.
_______________________________________________
Gnoga-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gnoga-list