Rick,
In your sample code for plUpload you make an ajax call to plupload.wwd. Can you paste here what you have in it please? I am trying to get your code to work in my app and not having any luck.
Thanks!
That's just a method in the controller class. Look for it in wwdemo.prg.
+++ Rick ---
Rick - thanks... I found it in wwdemo, copied it into my process prg, and hoped for the best. I have to assume my app is interfering somehow. Before I setup a call with you to help me figure it out, I have another question.
Can you tell me roughly when you added the following function to wwUtils?
************************************************************************
* FormatString
****************************************
*** Function: Uses a string template to embed formatted values
*** into a string.
*** Assume:
*** Pass:
*** Return:
************************************************************************
FUNCTION FormatString(lcFormat, lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8,lv9,lv10)
LOCAL lnParms, loBridge
lnParms = PCOUNT()
loBridge = EVALUATE("GetwwDotnetBridge()")
DO CASE
CASE lnParms = 2
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1)
CASE lnParms = 3
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2)
CASE lnParms = 4
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3)
CASE lnParms = 5
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4)
CASE lnParms = 6
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5)
CASE lnParms = 7
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5,lv6)
CASE lnParms = 8
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5,lv6,lv7)
CASE lnParms = 9
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8)
CASE lnParms = 10
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8,lv9)
CASE lnParms = 11
RETURN loBridge.InvokeStaticMethod("System.String","Format",lcFormat,lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8,lv10)
OTHERWISE
THROW "Too many parameters for FormatString"
ENDCASE
ENDFUNC
It's relatively recent - 6.0 timeframe.
Thanks.
Getting back to the original request.
When I try to run the sample plupload "plUpload Queue Component UI Example", my web server (IIS Win 7) is throwing a - HTTP/1.1 500 Server Error. You can see below what I get from the post... All seems fine. The trouble comes when the plupload class instantiates, it cannot read the inbound stream. I do not have 6.x loaded in its entirety, so I presume I am missing some dependencies. I am hoping you have seen enough to say 'ah hah' you need to update your class ___.prg's (maybe its wwUtils?)
You can test if you'd like (ha ha) here - https://michael.sophio.com/files.wws
******** Form Variables ********
------moxieboundary1518184649913
Content-Disposition: form-data; name="name"
thenewcool.png
------moxieboundary1518184649913
Content-Disposition: form-data; name="chunk"
0
------moxieboundary1518184649913
Content-Disposition: form-data; name="chunks"
9
------moxieboundary1518184649913
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream
‰PNG
I don't know - lcFilename is empty and you're not showing the obvious: Where is the filename coming from?
Old versions used different syntax for getting multi-part form variables so that's likely your problem. You need to use GetMultipartFormVar()
most likely.
+++ Rick ---
Rick - all of the code comes from your example, that's why I was asking. Suffice to say your last response certainly solved the issue. However, there were other requests that needed the same function to solve the whole issue. I added a few if..endifs to your to your method which I recommend you consider adding as well because I have to assume most of the folks who try this will have same issue.
This code is in the plUploadHandler.prg that comes with wwwc
FUNCTION ProcessRequest()
LOCAL lnChunk,lnChunks, lcFileData, lcFilename, loUpload
lcFilename = Request.Form("name")
IF EMPTY(lcFileName)
lcFileName = ""
ENDIF
* added by mb
IF EMPTY(lcFileName)
lcFileName = Request.getmultipartformvar('name')
endif
*** Make sure the filename is normalized
*** and paths are stripped to avoid path traversal attacks
lcFileName = JUSTFNAME(lcFileName)
lnChunks = VAL(Request.Form("chunks"))
* added by mb
IF lnChunks = 0
lnChunks = VAL(Request.getmultipartformvar("chunks"))
endif
lnChunk = VAL(Request.Form("chunk"))
* added by mb
IF lnChunk = 0
lnChunks = VAL(Request.getmultipartformvar("chunk"))
endif
lcFileData = Request.GetMultiPartFile("file")
Rick last question about this ( I hope 😉 ). I have your demo code mostly working now, but it seems to only work with PNG files. If I upload a jpg or gif the file does get saved to my server, but when the browser tries to render the file after upload, it appears broken.
https://michael.sophio.com/files.wws - if you want to try it...
Don't know - if it works for one it should work for the other unless you're blocking the upload. I think the default implementation allows only for image uploads with an extension check.
+++ Rick ---
Rick - Thanks for saying that. I debugged again and guess what I found - a bug that yours truly injected into the base class when testing something! Imagine that (wink).
Below is the code I added that was needed to get the samples to work in my environment. I don't have your latest version unpacked yet so I was not able to compare. Maybe this will help someone who's in a mixed state of upgrade like me.
************************************************************************
* ProcessRequest
****************************************
*** Function: This method receives all incoming plUpload requests
*** and
*** Assume:
*** Pass:
*** Return:
************************************************************************
FUNCTION ProcessRequest()
LOCAL lnChunk,lnChunks, lcFileData, lcFilename, loUpload
lcFilename = Request.Form("name")
IF EMPTY(lcFileName)
lcFileName = ""
ENDIF
IF EMPTY(lcFileName)
lcFileName = Request.getmultipartformvar('name')
endif
*** Make sure the filename is normalized
*** and paths are stripped to avoid path traversal attacks
lcFileName = JUSTFNAME(lcFileName)
lnChunks = VAL(Request.Form("chunks"))
IF lnChunks = 0
lnChunks = VAL(Request.getmultipartformvar("chunks"))
endif
lnChunk = VAL(Request.Form("chunk"))
IF lnChunk = 0
lnChunk = VAL(Request.getmultipartformvar("chunk"))
endif
lcFileData = Request.GetMultiPartFile("file")
lcExt =LOWER(JUSTEXT(lcFileName))
IF EMPTY(lcExt) OR ATC("," + lcExt + ",","," + LOWER(this.cAllowedExtensions) + ",") < 1
This.WriteErrorResponse("Invalid file extension uploaded.")
RETURN
ENDIF
*** Upload Started
IF lnChunk = 0
*** Write out WriteErrorResponse from this handler
*** if the upload should not proceed
IF !this.OnUploadStarted(lcFileName,THIS)
RETURN
ENDIF
ENDIF
*** Handle/Writeout individual chunk
IF !this.OnUploadChunk(lcFileData, lnChunk, lnChunks, lcFileName,THIS)
RETURN
ENDIF
*** Upload Completed
IF lnChunk >= lnChunks - 1
this.OnUploadComplete(lcFileName,THIS)
RETURN
ENDIF
*** Write 'OK' repsonse to continue retrieving chunks
THIS.WriteSuccessResponse()
ENDFUNC
* ProcessRequest
All good now.