Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,

Is it possible to have a Windows Form in C++ 'communicate' with a PHP back-end with all functionality being on one PC?  I.e., the implementation of PHP in my case would be via XAMPP.

Specifically I'd like to have a C++ Windows Form as that has access to the PC file system, and then pass some data from the PC file system to a PHP back-end which would do some work on the file passed to it.  Once the work was done then some communication back to the Windows Form front-end to say that the work had been done.

I did something like this a few years ago with Adobe AIR as the front-end and PHP as the back end, but would now like to do something similar but with the Windows Form C++ as the font-end.

Looking forward to your advice.

Cheers from Oz.

Share this post


Link to post
Share on other sites

That should be "I did something like this a few years ago with Adobe AIR and FLEX....".  leveraging both your AIR and FLEX books.

Cheers

Share this post


Link to post
Share on other sites

I imagine it _may_ be possible but it's the kind of situation where I feel like the answer is "this is probably not what you should be doing". In that it feels like you're only using PHP here because you're most comfortable with it. If you're starting with C++, my inclination would be to try to do all the work in C++. But let me know if I'm missing something.

Share this post


Link to post
Share on other sites

Hi Larry,

I want the front end to be C++ so that I have access to the PC file system.  Apparently it can be done with cpprestsdk and I will check it out.  I wonder if I could do it the other way around with PHP on the server calling a C++ module on my PC to get access to the PC file system?  I want to access a directory on the PC which, apparently cannot be done with PHP or an HTML form.  I want the full path of the directory, not an upload.

Re being comfortable with PHP - yes you are right on that count but I'm learning a lot more of C++ particularly using Visual Studio as the IDE which has nice PC forms functionality.

Thanks for your reply.

Cheers

Share this post


Link to post
Share on other sites

Ah, okay. If PHP is running on your PC (on a webserver there) you can definitely access the file system using PHP. 

Share this post


Link to post
Share on other sites

Hi Larry,

Yes, I can access the contents of a file but can I get access to its full path - the application will be running on my PC with PHP via localhost/XAMPP?

Thanks, Necuima

Share this post


Link to post
Share on other sites

Hi Larry,

FYI I installed cpprestsdk and associated it with Visual Studio 2019 and yes, a test C++ program successfully called and received a response from an external website.

BUT (isn't there often a BUT) when I tried to integrate the code that uses cpprestsdk into a Windows form application, I found out that they are incompatible!

Well, it was an interesting learning exercise :-)

As an aside, I found it quite tricky to install cpprestsdk but carefully following guidance courtesy Dr Google I eventually managed to get it installed and working with VS2019 (but not VS2017) in a Windows 10 PC.

Thanks for your interest.

Edited by Necuima
Added some more information

Share this post


Link to post
Share on other sites

Thanks for the update. I'm still a bit confused by the scenario. If PHP is running on the same Windows machine as the files, then it should be able to access the full path. If not in the web version of PHP (presumably due to permissions), then the command-line PHP can. Apologies if I'm missing something.

Share this post


Link to post
Share on other sites

Hi Larry,

I am missing something.  I select a file or a directory on my PC in a PHP script which includes an HTML form and within the form I use upload.  Then on the redux pass I can move that file to a server location and do some stuff with it.  No problem.  But what I want to do is do some stuff to the file on the PC which I can do if I know the full path of the selected file.  And in a slightly different PHP script I want to select a directory on my PC and get its full path so that I can then iterate over the files therein and do stuff to them.

What am I missing? And thank you as always.

Cheers

P.S., using a C++ front end or a Flash front-end program I can get the full path names of files and directories on my PC.  Then, at least the Flash case, I can pass those data to a PHP back-end which nicely does what I want it to do for those selected files on my PC.  I do not want this functionality for files on an external web-server.

Edited by Necuima
Added more information

Share this post


Link to post
Share on other sites

P.S., The Flash program is a windowed FLEX application and as mentioned, this works perfectly with the called PHP scripts on XAMPP.

Share this post


Link to post
Share on other sites

Ah, okay. Thanks for explaining! I guess my inclination in this case would be to make a command-line utility that does the work you want to do and you provide this utility with the path to a file when you invoke it. The main issue in my mind is that "uploading" a file from a computer to itself is a marker of making a process more complicated than it needs to be. 

You could also write the command-line utility to accept a directory as an argument and then iterate through that directory. 

Let me know if this is still unclear. 

Share this post


Link to post
Share on other sites

Hi Larry,

Thanks as always for your interest and advice.

As an aside I had not used FLEX/WindowedApplication for a few years so I was a bit rusty but all OK again now.  Referred to your FLEX and AIR books both of which I have.  I now have the application working just fine on both Win7/PHP 5.6 and on a separate computer with Win 10 and PHP 7.1

Cheers from Oz, Necuima

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...