Jump to content

Issues with reading/writing to a file


aleminio

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/265539-issues-with-readingwriting-to-a-file/
Share on other sites

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');

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.