Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old June 26th, 2009, 04:14 PM
Member
 
Join Date: Jun 2009
Posts: 52
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.
  #2  
Old June 26th, 2009, 04:18 PM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,862
Provided Answers: 9

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.
  #3  
Old June 26th, 2009, 04:22 PM
Member
 
Join Date: Jun 2009
Posts: 52

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.
  #4  
Old June 26th, 2009, 04:32 PM
Member
 
Join Date: Jun 2009
Posts: 52

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.=)
  #5  
Old June 26th, 2009, 05:30 PM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,862
Provided Answers: 9

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.
  #6  
Old June 27th, 2009, 06:49 PM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,701
Provided Answers: 4

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[function.copy]: failed to open stream: No such file or directory ghasembaghi answers 14 February 17th, 2009 10:24 PM
Problem in reading a file from database robin1983 answers 4 November 24th, 2007 07:50 AM
Warning: fopen() [function.fopen]: failed to open stream: No such file or directory siyaverma answers 3 September 21st, 2007 03:41 PM
Simple text file reading codes NOT working Jofio answers 3 October 18th, 2005 02:35 PM