Web Connection
POST
Gravatar is a globally recognized avatar based on your email address. POST
  Edward K. Marois
  All
  May 7, 2019 @ 12:34pm

Dear Rick:

I have made amazing progress with Web.connection

I would like to transfer a 'RISDESK.ZIP' from my workstation to the web

This has proven to be extremely difficut

I try to run FileUpload.wwd as it appears in the 'demo' and I get the error * 'The server is not setup to handle this type of Request:' where the request is blank

I added '.wwd' in the web.confing and re-ran the installation program ... no effect.

I tried to the bellow script and tried to load the script

oHttp = CREATEOBJECT("wwHTTP")

*** Set mode to multi-part form
oHttp.nHttpPostMode = 2

*** Post a file and a regular form variable
oHttp.AddPostKey("upload","C:\RISWIN\TEMP\RISDESK.ZIP",.T.,"")

And I cannot for the life of me figure out how to load the FileUpload.wwd script

I am running out of time.

I would like to skip over the 'FileUpload.wwd' and just save the file on the web server

Please, Please, Please

Could you give me the code to do this one simple thing

Please ...

Gravatar is a globally recognized avatar based on your email address. re: POST
  Rick Strahl
  Edward K. Marois
  May 7, 2019 @ 02:01pm

I'm not quite sure what you're asking...

I would like to skip over the 'FileUpload.wwd' and just save the file on the web server

What does that mean?

I think what you want on the client is this:

oHttp = CREATEOBJECT("wwHTTP")

*** Set mode to multi-part form
oHttp.nHttpPostMode = 2

*** Post a file and a regular form variable
oHttp.AddPostKey("upload","C:\RISWIN\TEMP\RISDESK.ZIP",.T.,"")

lcResponse = oHttp.Post("https://localhost/wconnect/fileupload.wwd")
Gravatar is a globally recognized avatar based on your email address. re: POST
  Edward K. Marois
  Rick Strahl
  May 8, 2019 @ 08:14am

oHttp = CREATEOBJECT("wwHTTP")

*!*    *** Set mode to multi-part form
oHttp.nHttpPostMode = 4

*!*    *** Post a file and a regular form variable
oHttp.AddPostKey("upload","C:\RISWIN\TEMP\RISDESK.ZIP",.T.,"")

*o.Put(lcUrl, lcUserName, lcPassword, lcOutputFile)

oHttp.Send("http://localhost:7000/","","","RISDESK.ZIP")

Your close but this works just fine ...

Gravatar is a globally recognized avatar based on your email address. re: POST
  Rick Strahl
  Edward K. Marois
  May 8, 2019 @ 04:07pm

Uh... that code is not really valid. I don't know what that actually would do but it's not the right approach IMHO.

You have two choices for uploading a file:

  • Use a multi-part form as in the example I posted earlier in this thread
  • Send a raw file with a Content type

The latter is:

loHttp = CREATEOBJECT("wwHttp")

*** Specify that we want to post raw data and a custom content type
loHttp.cContentType = "application/json"  && Content type of the data posted

*** Load up the XML data any way you need
lcJson = FILETOSTR("Data.json")

*** Set the POST buffer - Note: No name parameter, just the buffer
loHttp.AddPostKey(lcJson)

lcResult = loHttp.Post("http://www.myserver.com/SomeEndpoint.wwd")

To grab this on the server:

lcData = Response.Form()

Take a look at the docs for raw uploads:

And for Multi-part uploads:

On the server:

lcFileName = ""
Response.Form("MyUploadedFileVar",@lcFilename)  

Note that multi-part is by far the more common approach because almost always you need some additional data that is associated with the upload - file name, id, size, location, customer id etc. and using multi-part forms allows you to send that as part of the post data.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: POST
  Edward K. Marois
  POST
  May 9, 2019 @ 09:10am
loHttp = CREATEOBJECT("wwHttp")

*** Specify that we want to post raw data with a custom content type
loHttp.cContentType = "application/zip" 

lcPdf = FILETOSTR("C:\RISWIN\TEMP\RISDESK.ZIP")
loHttp.AddPostKey(lcPdf)  && Add as raw string

*** Send to server and retrieve result
lcHtml = loHttp.Post("http://www.risdesk.com/FileUpload_TEN2.wp")

I created a 'FileUpload_TEN2.wp' on the web server just so that the POST command will have something to grab onto and put the 'lcData = Response.Form()' in it ...

I run this and I get a "Property POST not found' Error

Does this mean that the 'loHttp.Post' is not present or that the "http://www.risdesk.com/FileUpload_TEN2.wp" is not present ???

Gravatar is a globally recognized avatar based on your email address. re: POST
  Edward K. Marois
  Edward K. Marois
  May 9, 2019 @ 10:43am

Dear Rick:

I ran the latest update and the existing problem was cleared up

I got the message 'Property FORM not found on' the web server.

This is a clear indication that the FileUpload_TEN2.wp is NOT configured properly

Please disregard last message ...

Gravatar is a globally recognized avatar based on your email address. re: POST
  Rick Strahl
  Edward K. Marois
  May 9, 2019 @ 01:27pm

Nope - if Response.Form() doesn't work there's something else wrong, but the fact it says Property not found is an indicator you're not calling it correctly.

© 1996-2019