NetTalk Central

Author Topic: How to allow file upload in an NT8 Webservice  (Read 3326 times)

debzidoodle

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
    • Email
How to allow file upload in an NT8 Webservice
« on: July 02, 2014, 12:31:06 PM »
Hi All,

How can I upload a picture or file to a WebServiceMethod?  Ideally I would like to be able to upload more than one file at a time, but not required. 

It does not have to be done via a WebServiceMethod, but I am a little confused by this post http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=5150.0
The part that confuses me is using the web page, so do I create by own form in a routine? And if so how do I access the values and file upload from the form?

Thanks

Debra

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: How to allow file upload in an NT8 Webservice
« Reply #1 on: July 02, 2014, 11:36:40 PM »
Hi Debra,

create NetTalkPage and declare ST as a StringTheory object after that in page embed put code like this     
ST.SetValue(p_web.GetValue('_postdata_'))
ST.SaveFile('WHENEVERYOUWANT\WHATEVERYOUWANT.BIN')

Then with that file do it what you want.  :)

Best regards,

Djordje Radovanovic

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to allow file upload in an NT8 Webservice
« Reply #2 on: July 03, 2014, 01:09:03 AM »
>> How can I upload a picture or file to a WebServiceMethod?

Because it's a webServiceMethod I presume you are uploading from a client which is not a Browser.

so there are 2 directions to take, based on the Client's method of choice.

a) do a POST from the client, including the file using "normal http post" techniques (which in say a NetTalk Web client means doing a
net.SetValue(fieldname,filename,true) [ from memory - so I don't know if the syntax is correct. ]

or
b) embed the file inside the incoming XML as a parameter, usually base64 encoded or something.

In the case of a) you can follow the instructions on the other thread - the incoming file is just in a Value.
In the case of b) you'd make the field a large string parameter (like any other parameter) and then you'd need to decode it and save it (probably using StringTheory.)

Cheers
Bruce

debzidoodle

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
    • Email
Re: How to allow file upload in an NT8 Webservice
« Reply #3 on: July 07, 2014, 06:36:20 AM »
Thanks Bruce and Djordje.  With the explanation Bruce gave in the user group meeting #25 I got it worked out!

Thanks
Debra