Web Hosting Forum | Lunarpages
News: October 6, 2008 - Submit Your Site for the October 2008 Site of the Month!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 06, 2008, 07:40:09 AM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: PHP File writing to a folder at same level as PUBLIC_HTML  (Read 765 times)
josephlevin
Newbie
*
Offline Offline

Posts: 2


« on: March 03, 2008, 07:33:46 AM »

Hello All!

I am trying to create a file to be written-to within a folder at the same tree-level as PUBLIC_HTML (hopefully this would prevent the file being accessed via a web browser via http) .

For example, an abbreviated list of the typical hosting account directory tree looks like:

/
/public_html
/www
/blah
/blah
/blah

Your website goes inside of /public_html, etc.

What I want is to create and write to a file via a PHP script. The file will be located in this folder: /000_output

so my "new" directory tree looks like:

/public_html
/www
/000_output
/blah
/blah
/blah

I set the folder permissions for 000_output to 755.

I have selected my directory path string to be equal to: /home/porta28/000_output

The problem is- the script executes without having a path not found type of error, but DOES NOT write the output file, "feedback.txt".  Sad


Note that if I set my folder to be

"/myweb/myclient/000_output"

The site assumes that I am referring to a folder within my website, as is expected, the script works fine, and writes to "feedback.txt" without a problem.  Thumbs Up

Can anyone tell me how I can write to a folder on the same level as public_html??  Confused

Thanks in advance!

-josephlevin


Logged
scanman20
Master Jedi
*****
Offline Offline

Posts: 1247



WWW
« Reply #1 on: March 03, 2008, 11:16:06 AM »

Have you tested setting the folder permissions to 777?
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
josephlevin
Newbie
*
Offline Offline

Posts: 2


« Reply #2 on: March 03, 2008, 03:27:17 PM »

Actually, I did do that (but that didn't work either).
In any event Lunarpages Tech Support said to me that only 755 was acceptable when write access was desired.

Logged
MrPhil
Quantum Encyclopedia Writer
*****
Offline Offline

Posts: 3381



« Reply #3 on: March 03, 2008, 06:41:21 PM »

LP runs security software "suPHP", which forbids world-writable directories and files (e.g., 777 permissions). 755 should be adequate if a script on your site is trying to write to your site.

Keep in mind that HTML sees its "root" (/) in public_html/ (for the primary domain), while PHP sees "root" (/) as the filesystem's true root. Thus for PHP, if you want to give absolute paths, you have to use /home/porta28/000_output/. PHP should certainly be able to read and write files outside of the public_html/ tree (not accessible to HTML or a browser), but HTML can't.

If the permissions are correct (755), please give us a simple example of code that fails to create "feedback.txt". Of course, you either erased any existing copy of "feedback.txt", or at least changed its permissions to 644, before running your test, right?
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM