Jurik Posted October 17, 2006 Share Posted October 17, 2006 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 havechdir ('\\PCnameonnetwprk\\thefolder\\');This does not seem to work however can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/ Share on other sites More sharing options...
HuggieBear Posted October 17, 2006 Share Posted October 17, 2006 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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109952 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 hhhmmm no im still getting Warning: chdir(): No such file or directory (errno 2) in location of file on line 29its 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? Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109956 Share on other sites More sharing options...
HuggieBear Posted October 17, 2006 Share Posted October 17, 2006 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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109958 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 [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]RegardsHuggie[/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. Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109962 Share on other sites More sharing options...
HuggieBear Posted October 17, 2006 Share Posted October 17, 2006 OK, php is probably dealing with the escaping slightly different to Perl which I'm used to...I'll take another look.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109964 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109985 Share on other sites More sharing options...
HuggieBear Posted October 17, 2006 Share Posted October 17, 2006 Maybe it's the rest of the code... Are you able to provide us with it?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109987 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 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]<?phpif (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 Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-109992 Share on other sites More sharing options...
craygo Posted October 17, 2006 Share Posted October 17, 2006 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 Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-110004 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 [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 Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-110008 Share on other sites More sharing options...
craygo Posted October 17, 2006 Share Posted October 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-110015 Share on other sites More sharing options...
Jurik Posted October 17, 2006 Author Share Posted October 17, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-110041 Share on other sites More sharing options...
craygo Posted October 17, 2006 Share Posted October 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24195-using-chdir-over-a-network/#findComment-110045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.