PDA

View Full Version : cWebFileUploadButton for wordpress - dataflex 18.2



sandrobrz
14-Dec-2016, 11:44 AM
Hi, I'm converting my web application to work with wordpress.

I came across a problem with the cWebFileUploadButton class.

When I run wordpress to call the application and try to send a file by clicking the button, I get the error message Received HTTP ERROR '404 Not Found' while uploading file.

However, if I call the same application by putting the path in the browser, it works perfectly.

I think this class also has to be ported to wordpress.

Any suggestions on how to work around the problem until the class is ported.

Mike Peat
15-Dec-2016, 03:49 AM
Sandro

I'll have a quick look at it and get back to you - I think we will probably need a cWP version of the class.

Mike

Mike Peat
15-Dec-2016, 04:39 AM
Sandro

Entirely untested, in the interest of getting you a quick fix you can try, put this code into a new class package, cWPFileUploadButton.pkg and use that in you code, then let me know how it goes:



Use cWebFileUploadButton.pkg

Class cWPWebFileUploadButton is a cWebFileUploadButton

Function psUploadUrl Returns String
String sURL sHome sHost sPort
Integer iPos

Forward Get psUploadUrl to sURL
Move (ServerVariable(ghoWebServiceDispatcher, "SERVER_NAME")) to sHost
Move (ServerVariable(ghoWebServiceDispatcher, "SERVER_PORT")) to sPort
Move (ServerVariable(ghoWebServiceDispatcher, "URL")) to sHome
Move (Pos("WebServiceDispatcher.wso", sHome)) to iPos
Move (Left(sHome, (iPos - 1))) to sHome
Move ("//" + sHost + ":" +sPort + sHome + sURL) to sURL
Function_Return sURL
End_Function


End_Class


Mike

Mike Peat
15-Dec-2016, 05:19 AM
Sandro

Oops! Just spotted the fact that it should be "Function psUploadUrl Returns String". I have now edited the original, so you can ignore this post if you hadn't grabbed it aleady.

Mike

sandrobrz
16-Dec-2016, 08:29 AM
Hi, Mike.
I created the class and tested it and got error 405 - method not allowed.

Mike Peat
17-Dec-2016, 07:33 AM
Sandro

Oh well, worth a try I suppose. I will have to look into it more fully, which probably won't happen till Monday now.

I'll get back to you.

Mike

Mike Peat
20-Dec-2016, 10:22 AM
Sandro

OK, this is a bit trickier than I'd thought.  The DF upload mechanism does some clever stuff (I really want to say "spooky stuff", but that would be unprofessional!) which just isn't going to work under WordPress without some modification of the client-side JavaScript (I think).

Watch this space...

Mike

Mike Peat
20-Dec-2016, 11:45 AM
OK Sandro

I have a nasty kludge-fix that you might like to try in the short term, until we can come up with a nicer solution.

The issue is that the DataFlex upload mechanism (for the moment) uses an old-style ASP file to actually manage the uploads. This is NOT set in the cFileUploadButton (or one of its ancestors), but is hard-coded as "DFEngine/Upload.asp" into cWebResourceManager.pkg.

Now when your app is running under WordPress that relative path doesn't work - it needs to be explicitly pointed to it. As a very nasty fix, just for now, try in WebApp.src, somewhere after the line "Use WebResourceManager.wo", add a line something like:



Set psUploadUrl of ghoWebResourceManager to "//DFAppHost/DFAppVirtualDir/DFEngine/Upload.asp"


or if your app is running on the same machine as the WordPress site, just:



Set psUploadUrl of ghoWebResourceManager to "/DFAppVirtualDir/DFEngine/Upload.asp"


See if that works.

Mike

Mike Peat
21-Dec-2016, 10:33 AM
Sandro

OK, I think I have a better fix for your problem. Attached is WPWebResourceManager.wo. Download that to your DF4WPLib directory, then change your WebApp.src to "Use WPWebResourceManager.wo" instead of the standard WebResourceManager.wo, recompile and see if it fixes your issue.

Mike

sandrobrz
26-Dec-2016, 12:44 PM
Hi Mike
Did not work, see error : Received error "Invalid resource string" while uploading file

Mike Peat
28-Dec-2016, 10:27 AM
Sandro

Could you check the Event Log for your app (in Web App Administrator) for an error like: "Attempt to upload to an unregistered upload folder...", which might be the cause of the problem (i.e. unconnected with running under WordPress). I don't actually think that is the problem, but it is worth checking before getting into anything else.

Mike

Mike Peat
5-Jan-2017, 04:37 AM
Hey Sandro - any news on the WebApp Event log?

Mike

Wim Schimmel
25-Jan-2017, 03:16 AM
Hi Mike

This works (Use WPWebResourceManager.wo)

Thanks

Wim

Wim Schimmel
25-Jan-2017, 04:15 AM
Hi Mike

This works (Use WPWebResourceManager.wo)

Thanks

Wim