Jump to content


Photo

Using chdir over a network


  • Please log in to reply
13 replies to this topic

#1 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 10:46 AM

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?

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 10:52 AM

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

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


Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 10:57 AM

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?

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 11:00 AM

I didn't realise the single quotes... Try this sorry...

chdir("\\\\PCnameonnetwprk\\thefolder\\");

or this:

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

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 11:05 AM

I didn't realise the single quotes... Try this sorry...

chdir("\\\\PCnameonnetwprk\\thefolder\\");

or this:

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

Regards
Huggie


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.

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 11:08 AM

OK, php is probably dealing with the escaping slightly different to Perl which I'm used to...

I'll take another look.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 12:24 PM

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?

#8 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 12:40 PM

Maybe it's the rest of the code... Are you able to provide us with it?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#9 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 12:49 PM

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.

<?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.";

?>


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

#10 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:05 PM

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

#11 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 01:12 PM

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


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

#12 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:26 PM

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_computername. 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

#13 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 October 2006 - 02:00 PM

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?

#14 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 02:06 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users