aleminio Posted July 11, 2012 Share Posted July 11, 2012 Hey guys, I'm using Apache on a linux server. I have a file in the following location : /home/stream/playlists.lst permissions are set to 0777 and even the owner/group are set to the one used by apache - "apache". I'm trying to read the file i mentioned from a php script located here: /home/admin/somedomain/index.php I'm accessing this index file using the domain or the ip allocated to that domain, but it fails. telling me that the target file(playlist.lst) is unreadable/unwritable. but if I'm trying to read other files located in the user folder (home/admin/somedomain) it does work. The weird thing is, if I'm using my second IP address that's allocated to my server, in order to access user's default domain in Kloxo, (the following way; http://256.256.256.256/~admin) which points to the same php file that i had issues with, then it suddenly works ! so what has changed exactly? The only thing i can think of is that apache/php doesn't let me access files outside my user root folder if the site's IP address is not the localhost one. but then why doesn't it consider my second IP address as my server's IP. I really don't know and would appreciate any ideas. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/265539-issues-with-readingwriting-to-a-file/ Share on other sites More sharing options...
redarrow Posted July 12, 2012 Share Posted July 12, 2012 try this as a test read this as well http://phpsense.com/2006/php-ftp-functions/ <?php $dir = 'myDir'; // create new directory with 777 permissions if it does not exist yet // owner will be the user/group the PHP script is run under if ( !file_exists($dir) ) { mkdir ($dir, 0777); } file_put_contents ($dir.'/test.txt', 'Hello File'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/265539-issues-with-readingwriting-to-a-file/#findComment-1360956 Share on other sites More sharing options...
scootstah Posted July 12, 2012 Share Posted July 12, 2012 I'm not sure I fully understand your post, but you can't read remote files with PHP without using something like FTP. Quote Link to comment https://forums.phpfreaks.com/topic/265539-issues-with-readingwriting-to-a-file/#findComment-1360974 Share on other sites More sharing options...
xyph Posted July 12, 2012 Share Posted July 12, 2012 I'm not sure I fully understand your post, but you can't read remote files with PHP without using something like FTP. Assuming they aren't web-accessible. Quote Link to comment https://forums.phpfreaks.com/topic/265539-issues-with-readingwriting-to-a-file/#findComment-1360989 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.