ftp - php Failed to open stream error for some users but not others -


i've been searching stackexchange topics on error not have found mirror i'm experiencing.

my current state have web page contains visualization set d3.js of objects clickable. upon clicking on 1 of them, php script executed via ajax (with variables passed base on object clicked) query run mssql database returns list of images retrieved via ftp. far know part working.

the code hosted on win 2008 r2 server running iis.

after retrieving array of images, loop executed see if have been downloaded and, if not, image fetched via ftp in loop below:

        if(in_array($filename,$files)) {             //*** see if image has been ftp'd             $fileto = "c:/inetpub/wwwroot/iris/images/" . $filename;         } else {             $ftp_host = $wrow["serverid"] . ".prod.com";              // *** create ftp object             $ftpobj = new ftpclient();              // *** connect             try{                 $ftpobj->connect($ftp_host,$ftp_user,$ftp_pass);             } catch (pdoexception $uc) {                 header('content-type: application/json');                 echo json_encode("error making ftp connection");                 die();             }              $filefrom = $wrow["filespec"];             $fileto = "c:/inetpub/wwwroot/iris/images/" . $filename;              try {                 $ftpobj->downloadfile($filefrom,$fileto);             }catch (pdoexception $uc) {                 header('content-type: application/json');                 echo json_encode("error transfering file");                 die();             }         } 

the code makes final try/catch loop, making call ftp class have downloadfile resides. note in making connection same username , password used users.

in ftp_class.php connection follows:

public function connect ($server, $ftpuser, $ftppassword, $ispassive = false) {      // *** set basic connection     $this->connectionid = ftp_connect($server);      // *** login username , password     $loginresult = ftp_login($this->connectionid, $ftpuser, $ftppassword);      // *** sets passive mode on/off (default off)     ftp_pasv($this->connectionid, $ispassive);      // *** check connection     if ((!$this->connectionid) || (!$loginresult)) {         $this->logmessage('ftp connection has failed!',true);         $this->logmessage('attempted connect ' . $server . ' user ' . $ftpuser, true);         return false;     } else {         $this->logmessage('connected ' . $server . ', user ' . $ftpuser);         $this->loginok = true;         return true;     } } 

and download file follows:

 public function downloadfile($filefrom,$fileto) {     $asciiarray = array('txt','csv');     $extension = end(explode('.',$filefrom));      if(in_array($extension,$asciiarray)) {         $mode = ftp_ascii;     } else {         $mode = ftp_binary;     }      if(ftp_get($this->connectionid,$fileto,$filefrom,$mode,0)) {         $this->logmessage("file " . $fileto . " downloaded");         return true;     } else {         $this->logmessage("there error downloading file " . $fileto,true);         return false;     } } 

i manage security access application via active directory roles (this on corporate intranet) note, again, ftp username , password not rely on these roles.

here problem i'm running into. if server administrator tries fetch, save on server, , display, works fine. if users, not administrators, try same works fine users can't execute. since user has write files image folder (seen in path above), have made folder shareable active directory role require access , give them read , write priv's specific folder.

the error returned is:

warning: ftp_get(c:/inetpub/wwwroot/iris/images/041351w0006010251f00000064i04.jpg): failed open stream: permission denied in c:\inetpub\wwwroot\dred\ftp_class.php on line 113

warning: ftp_get(): error opening c:/inetpub/wwwroot/iris/images/041351w0006010251f00000064i04.jpg in c:\inetpub\wwwroot\dred\ftp_class.php on line 113

line 113 line ftp_get on (see above).

i have tried few things in troubleshooting:

  1. give active directory role administrator writes server (not going keep, experimenting): worked
  2. give active directory role full read/write/change access servers c-drive (again, testing), inetpub , and wwwroot: did not work
  3. setting ftp_pasv() true: did not work

i think that's it! advice appreciated.

after many hours of troubleshooting discovered problem. mentioned in question, goal ftp images images folder on local server embedded in web page. through windows file explorer trying provide write access folder sharing folder based on ad role. not enough.

what solved problem use security tab under system properties , provide write access defined image folder iis_iusrs. once in place, ftp process write image image folder.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -