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

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.