开发者

PHP Windows copy network

$tmpUploadFolder = "C:\\www\\intranet\\uploads";
//$finalUploadFolder = "file:////server//photos//overwrite";
$finalUploadFolder = "file://server/photos/overwrite";
//$finalUploadFolder = "\\\\server\\photos\\overwrite";
//$finalUploadFolder = "\\server\photos\overwrite";
//$finalUploadFolder = "P:\\overwrite";
//$finalUploadFolder = "P:/overwrite";

$from = $tmpUploadFolder . "\\" . $_REQUEST['ext'];
$to = $finalUploadFolder. "\\" . $_REQUEST['ext'];
copy($from, $to);

I am trying to do a PHP upload using a jquery tool. The Jquery tool nicely places the fi开发者_如何学编程le onto the PHP upload dir before the page submit. So i want to (upon post of the form) quickly move the file from it's tmp folder location (it'll already be there you see) to it's final destination on an image store server (I use the _REQUEST['ext'] variable to hold the filename jquery held.

Rest assured these paths are good they work lovely in dos. As you can see I have tried every known unc syntax I know.

I cannot for the life of me get php to work I have written a VBS "copy . file" and tried to trigger it under whost.exe via system() in php, i've downloaded the oldeskool runas.exe and tried to get it to copy via system(), I have used unc paths and network shares, and mapped network drives, I have made apache service "log on as " administraor and even a custom adhoc new user made just for this and given it full permissions

It works fine if I change P:\ to C:\

I KNOW IT'S EFECTIVE PERMISSONS RE: APACHE - BUT WE DO NOT RUN ACTIVE DIRECTORY AND I CAN'T GET IT TO WORK

it simply will not let me copy this file onto a network and this is a major major MAJOR problem child for me.

Is there a solution? If you are going to help me with things like "it's file permissions" then I am going to need a break down of exact and careful instructions because I am pulling my hair out because I know it's file permissions rights but I just can't get it to work

I am tired now.. please help?



ok I figured it out so for the benefit of those going after me here is the solution THAT WORKS

1.make sure php windows "apache2.2" service is running as a administrator user (I made a user called apacheusr and gave it a password and popped it into local administrators) you do this by right clicking properties on the "apache2.2" service in administrative tools->services and going to the logon tab->this account and picking the apacheusr

2.because I don't run active directory I made this apacheusr user on BOTH machines (phpserver/ imageserver) as a local administrator user and gave them BOTH the same username password and tick password never expires.

3.I then log in/out at least once onto windows with both these accounts. (don't ask me why but it seemed to help, it stopped the runasexe --that I gave up with-- moaning in dos)

4.finally on the php server right click share the destination folder on imageserver and make damn well sure this apacheusr can log in to that folder. The simplest way to do this is when you log/in/out as apacheusr on your php server and try to go to your image server folder - you then need to be on the imagesever and tick everything correctly in the share/permissions bit THEN the final bit is (where _REQUEST['ext'] is a file name EG: "pic.jpg")

$tmpUploadFolder = "C:\\www\\intranet\\uploads"; 
$finalUploadFolder = "\\\\server\\photos\\overwrite"; 
$from = $tmpUploadFolder . "\\" . $_REQUEST['ext']; 
$to = $finalUploadFolder. "\\" . $_REQUEST['ext']; 
copy($from, $to); 

The above code works!


In what environment do you run php? Apache? IIS? These run most of the time as a service with System Credentials and cannot access Network shares...

Change the Webserver Account to a User that can write and it should work (with one of those URLs at least)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜