We help IT Professionals succeed at work.
Get Started

php code to copy files from one internal server to another

Last Modified: 2013-03-14
I have a web page that displays a list of files that users may download from my network. (This is all intranet stuff so at least at this stage I'm not concerned with hacking, injections etc). I want to be able to let the user click on the file link and then have the server side code copy the file from the document server to the download area on the web server.  The user doesn't need to know where the original document came from or what it's original file name is/was.  I've gotten the code functional up to the point where I try to do the actual copy between the servers. I have ftp on the web server but NOT the document server.  I just need to do the copy itself using some form of IO function(s) if possible.  I've already got the code functional to the remote client end once I've gotten the file into the download area.  I just can't get the file to copy from the document server to the download area.

In php, I've attempted to use copy, shell_exec() and exec().  copy just returns false, Shell_exec and exec return 0 files copied. Since I'm shelling out from the web server side, would I still have a rights issue that may be blocking the copy? If so, I'm not aware of where to read/learn about setting up security rights for this process and help would be appreciated.  
I have also written a console executable and run it from the command prompt on the web server (hard coded the copy). It runs and completes normally.  When I run exec("MoveDocument.exe"), nothing happens.  No return value and nothing copies.  

I'm running PHP 5.3.9 on Windows 2k8R2 IIS 7. I've also checked my configuratoin and php safe mode configuration is off.

I know just enough about PHP configurations and IIS configurations to be dangerous. So, if you are able to help, please be explicit enough in your responses to help me find the appropriate documentation pieces to learn about what your suggesting. In my world, I'm a general practitioner, not a specialist.  

Thanx in advance for any thoughts.

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE