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 ...
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")
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 ...
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 ---
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 ???
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 ...