Fopen(), file permissions?

software development


Hey, all - I’m somewhat new to the file manipulation portion of PHP, and I’ve run into a curious thing. I’m trying to set up a way for a client to download a file from a non-web-accessible portion of their account. To do this, I’m using copy() to copy it from its original location to something under /home/username/ I can see the file from the shell, and doing a directory listing under PHP (a readdir loop) properly displays the file, but I get the following error when I use the following lines:

$new_dir = ‘/home/username/’;
fopen($new_dir . ‘filename.csv’,‘r’);

Warning: fopen(/home/username/ failed to open stream: No such file or directory in /home/.landry/username/ on line 44

[I’m changing all the values for anonymity, of course.]

Anyhow, even if I chmod the file to 755, I still can’t see it with fopen(). Could this have something to do with that strange .landry hidden directory stuck in the middle of the path? I assume this is some kind of mapping thing at Dreamhost that we don’t generally need to know about, but could this be screwing up my explicit paths?

I assume this doesn’t have anything to do with DH’s new policy about allow_url_fopen, as I’m using an explicit server path and not an http: url, right?

Thanks in advance for any help -



Never mind - I am a dingbat. I had a typo AND was using fopen incorrectly. A quick switch to readfile() with header calls at the beginning solved the problem nicely. Thanks anyway, everyone!