Jump to content

Archived

This topic is now archived and is closed to further replies.

Jurik

Using chdir over a network

Recommended Posts

Hi people im currently trying to get my php script to go to another folder on another server and then to delete a file from that folder. Before I simple used chdir to move from a folder that was located with my php script but since putting it over a network I simple cant get to to go to the folder. At the moment I have

chdir ('\\PCnameonnetwprk\\thefolder\\');

This does not seem to work however can anyone help me?

Share this post


Link to post
Share on other sites
You look like you've started to escape the back slashes, but not correctly for a network path.  Try this:

[code=php:0]chdir('\\\\PCnameonnetwprk\\thefolder\\');[/code]


Regards
Huggie

Share this post


Link to post
Share on other sites
hhhmmm no im still getting

Warning: chdir(): No such file or directory (errno 2) in location of file on line 29

its strange because I can add a file to the address no problems, it just cant seem to go to the address when deleting.

Any ideas?

Share this post


Link to post
Share on other sites
I didn't realise the single quotes... Try this sorry...

[code=php:0]chdir("\\\\PCnameonnetwprk\\thefolder\\");
[/code]

or this:

[code=php:0]chdir('\\PCnameonnetwprk\thefolder\');
[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites
[quote author=HuggieBear link=topic=111757.msg453046#msg453046 date=1161082830]
I didn't realise the single quotes... Try this sorry...

[code=php:0]chdir("\\\\PCnameonnetwprk\\thefolder\\");
[/code]

or this:

[code=php:0]chdir('\\PCnameonnetwprk\thefolder\');
[/code]

Regards
Huggie
[/quote]

hhhmmm that dont seem to work either, this is strange. If I use the top one I get the same error, if I use the one below it I get a parse error.

Share this post


Link to post
Share on other sites
OK, php is probably dealing with the escaping slightly different to Perl which I'm used to...

I'll take another look.

Regards
Huggie

Share this post


Link to post
Share on other sites
hhhmmmm have you had any luck yet? Ive been trying to get it to work but with no results, does anyone know what the problem could be or another way around it?

Share this post


Link to post
Share on other sites
Maybe it's the rest of the code... Are you able to provide us with it?

Regards
Huggie

Share this post


Link to post
Share on other sites
Sure here it is, it worked before when I changed the directory to a folder called videos that was in the same folder as my php files its only over the network it dont seem to work.

[quote]<?php

if (isset($_GET['ID'])) {
  $vidID = $_GET['ID'];
} else {
  $vidID = NULL;
}
$query = "SELECT * FROM videos WHERE ID = ('$vidID')";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
  extract($row);
  chdir ('//benin/videolibrary/');
  unlink($Videofile);
}

$query2 = "DELETE FROM videos WHERE ID = ('$vidID')";
$result2 = mysql_query($query2);


echo "The video has been deleted.";

?>[/quote]

chdir ('//benin/videolibrary/'); has been fiddled with so it anit the same as before just been trying to get it to work really thanks for the help tho

Share this post


Link to post
Share on other sites
It is most likely a permission problem and not a problem with your code. Try maping the directory you want and connect to it with a drive letter. I think you will still get the same error but worth a shot.

Ray

Share this post


Link to post
Share on other sites
[quote author=craygo link=topic=111757.msg453092#msg453092 date=1161090339]
It is most likely a permission problem and not a problem with your code. Try maping the directory you want and connect to it with a drive letter. I think you will still get the same error but worth a shot.

Ray
[/quote]

Yes I have done that and am still getting the same error code, I mapped it to the drive letter V: and so changed the code to V:\ that didnt work and nor did V:\videolibrary so you delieve it is a permission problem then, will I have to set the permission in the code or can I go it on the server, im guessing I can seeing as how im able to save to the driv with my add script

Share this post


Link to post
Share on other sites
On my network here at work, and as I understand it, also microsoft networks, you have to set the internet user, which in IIS is IUSR_[i]computername[/i]. This user has to be added to the target machine for access to it. Since I didn't have access to permissions on the target machine on my network I change the internet user on my computer to my account and everything worked fine. Everything with php uses the default user to access any recourse on the computer and network. So that user has to have proper permissioms.

I am not sure if you are using apache or not, but you may need to do the same. I do not know apache so someone else may be able to help.

Ray

Share this post


Link to post
Share on other sites
Well ive asked the guy at work and he says there shouldnt b any problems with permissions as they are all set. I can delete a file manualy from the space im trying to delete from it just seems to be my php that just cant seem to delete anything from. Hes mentioned ones running off a Linux would that be whats causing the problem?

Share this post


Link to post
Share on other sites
What is your setup.

What Operating system is the web server on??
What web server program you using IIS, Apache??
What OS is the target machine running on??

Ray

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.