Connecting Tech Pros Worldwide Forums | Help | Site Map

fopen: [function.file]: failed to open stream: No such file or directory

Member
 
Join Date: Jun 2009
Posts: 52
#1: Jun 26 '09
I've been having trouble trying to open a file. It outputs
Expand|Select|Wrap|Line Numbers
  1. fopen(/projects/CCPROT/ts_classes) [function.file]: failed to open stream: No such file or directory in /mnt/raid/www/intra/admin/ts2/test2.php on line 72
  2.  
I've tried outputting the file name and it's correct. I've looked online for help and it seems that people had to use trim() on the variable name and I did that but it still doesnt work. I'm opening this file when another file is open already (in a while loop) and I was wondering if that is causing the problem. If it isn't, I was wondering if anyone can shed some light on this problem. Thanks for the help.

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Jun 26 '09

re: fopen: [function.file]: failed to open stream: No such file or directory


Going to need a little more information. Even though the file path *looks* right, it isn't. Are you using an absolute path or relative path? I recommend absolute as you don't have to resolve directories then.

What does your path look like? Where is the script being executed from (what is the current working directory)?

- mark.
Member
 
Join Date: Jun 2009
Posts: 52
#3: Jun 26 '09

re: fopen: [function.file]: failed to open stream: No such file or directory


so this is where I try to open my file in line 72
Expand|Select|Wrap|Line Numbers
  1. if($project==$type){    
  2.                 $classpath="/projects/".$project."/ts_classes";
  3.                 $classfile=fopen("$classpath","r");
  4. }
  5.  
I believe I'm using an absolute path already cause I have the directory name in it already. The script is being executed from /projects/www/intra/admin/ts2 and the file im trying to open is in /projects/ts. So they're in the same root directory(not sure what it's called) but in different folders.
Member
 
Join Date: Jun 2009
Posts: 52
#4: Jun 26 '09

re: fopen: [function.file]: failed to open stream: No such file or directory


hm...so I think I fixed it by changing things to lower case. I didn't know it was case-sensitive. Hopefully, it fixed it for real and doesnt pop up agn later. Thanks for your help.=)
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#5: Jun 26 '09

re: fopen: [function.file]: failed to open stream: No such file or directory


Windows paths are case-insensitive I think, while pretty much every other OS is case sensitive.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,754
#6: Jun 27 '09

re: fopen: [function.file]: failed to open stream: No such file or directory


I believe some Macs are case-insensitive to, depending on the file-system being used. (Maybe a Windows compatibility thing... I don't know :P)
Reply