NetTalk Central

Author Topic: H5 file upload problem - solve it with NetTalk?  (Read 4442 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
H5 file upload problem - solve it with NetTalk?
« on: January 25, 2017, 03:55:55 AM »
Hi,

We're experimenting with H5 Bootstrap. I know this is a NT forum, but hopefully I can use H5 and NT in the same solution.

The one feature that's lacking in H5 is the ability to do a file upload. With a NT web service that has a file upload method, I was hoping to look at a way to use a client-side script to POST the file to the NT web service before the H5 form is submitted.

I also know that the WinHTTP object should be available in the client script, that can be used to do the POST. But that's about where my current understanding stops. Any ideas?

Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: H5 file upload problem - solve it with NetTalk?
« Reply #1 on: January 25, 2017, 07:22:19 AM »
Hi Thys,

I suspect that if you can get the H5 solution to do the file post to the API then you could indeed use the two together. Unfortunately though I have no understanding of the H5 classes, or H5 JavaScript so I've no real suggestions on how to do the client-side stuff there.

I recommend asking your question in the Clarion10 newsgroup - perhaps couched as an "API Client" question. Or perhaps someone else here has some suggestions.

Cheers
Bruce

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: H5 file upload problem - solve it with NetTalk?
« Reply #2 on: January 31, 2017, 11:48:02 PM »
Bruce,

As you might have seen, the response from the news group was minimal - and your response referring to Ajax was a good one, although we haven't found an answer yet.

I've gone ahead trying to get the page script to do the upload to my NT web service method. This method expects two parameters. FileExtension is a string parameter that contains only the extension of the file to receive (we change the name when saved to the uploads folder). FileContent is a StringTheory parameter for the file content. Attached is the POST request that the service received. For me it all seems all file - both parameters are present. FileExtension is in the URL and FileContent is in a body part. But the method says the FileContent parameter is blank or not present. What needs to be changed in the request?

Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: H5 file upload problem - solve it with NetTalk?
« Reply #3 on: February 01, 2017, 01:09:19 AM »
Hi Thys,

I agree, it all seems to look ok.
You've only made one (small) mistake.

>>  FileContent is a StringTheory parameter for the file content.

It should be a StrngTheory object, yes, but the parameter should be of type FILE.
(Not TABLE, that's something completely different and not StringTheory.)

Then I think you should be ok.

cheers
Bruce

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: H5 file upload problem - solve it with NetTalk?
« Reply #4 on: February 01, 2017, 03:27:46 AM »
Thanks Bruce.

I already had the type of FileContent set to FILE. The parameter is also set to be required, but I also had the "Not 0 or Blank" check on - after taking it off, the ServiceMethod routine then executed.

The LastError property now returns "Could not save the file, the string is empty" - which in a way confirms the original problem that the StringTheory variable did not receive the file content.

In the POST request, is the location of the "FileContent" parameter correct?

Thys