Hey!

Thanks Joakim for the super-quick reply! :)

I'll take a look at the forms demo, thanks!

I think the full page reload is just fine for now. Maybe if I get the other
stuff to work as the way I intended, I might be interested in more fancy
operation like ajax for it.

-Henrik

On Tue, Oct 1, 2019 at 11:10 AM Joakim Dahlgren Strandberg <joaki...@kth.se>
wrote:

> 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 <hehar...@iki.fi>
> *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
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list
>
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list

Reply via email to