Mac. PHP. fopen( ) does not create a file. Permissions.


 
Thread Tools Search this Thread
Top Forums Web Development Mac. PHP. fopen( ) does not create a file. Permissions.
# 1  
Old 03-01-2014
Mac. PHP. fopen( ) does not create a file. Permissions.

Thank you to those who responded.
After a crazy amount of troubleshooting and getting hints and feedback from others, I was so darn determined to get on with my tutorials and I found the solution myself.

Keyword search: php and 'Mac computer' and fopen and chmod.
Using: php and Mac and fopen() didn't get me there.

I hope this forum allow for URL insertion. Others do.
PHP fopen() not creating file. - MacRumors Forums


1. This is the solution that I used.
It was all about PERMISSIONS and I used the Mac Finder.


This is my DocumentRoot path: /Library/WebServer/Documents
This is the path to the directory where I am saving all of my example programs from tutorials:
/Library/WebServer/Documents/phpWithAlex

This was how I went about troubleshooting this just to make certain that I was clear about at which level I needed to allow 'read and write' permissions. I should have started from php/WithAlex but I started on the top.

From the Mac Finder I navigated to Library and changed permissions to 'read and write' at all 3 levels:
System
Wheel
Everyone.
From the Mac Finder I navigated to WebServer and changed permissions to 'read and write' at all 3 levels:
System
Wheel
Everyone.
From the Mac Finder I navigated to Documents and changed permissions to 'read and write' at all 3 levels:
System
Wheel
Everyone.

I kept running the code which uses the fopen() function each time to see if I was able to create a new file and that this file ACCEPTED DATA input from my form.


The code which is in the previous post, DID INDEED CREATE the file when I used FOPEN() once I changed permissions to 'read and write' for all levels on phpWithAlex.

2.
Then I worked for the bottom back up the tree and reset permissions to just 'read' etc. etc.
I wanted to find out the least amount of permissions required to run the code.
The only folder that requires permissions set to 'read and write' for all 3 levels: system, wheel, everyone Was phpWithAlex.

3. I like to work at the command line.
You can use terminal on a Mac and set permissions using the chmod() function. Here is the link.... Which explains many things and also why you may or may not want certain permissions at different levels.

permissions - How to set chmod for a folder and all of its subfolders and files in Linux Ubuntu Terminal? - Stack Overflow

4.
If you read the last post, you will notice that I also modified my phi.ini and I ; un-commented a line
to find out if this allowed fopen() to work. It did not.
Then i set the ;comment =On rather than = Off etc. etc. it still did not allow fopen to work.
I am on a tablet or I would just copy paste those lines of code here.
If I leave this page and go to another and come back, this entire post disappears.
I learned that the hard way and had to start the post all over again.
I actually was curious so I put the ;comment back and it did not reintroduce the obstacle that I started with,
that fopen() would NOT create the file.

5.
I am posting this exact post on 5 other forums that I am now frequenting because it was very time consuming to find this resolution. Although, this exact problem was not resolved from these forums
, I LEARNED A TON FROM VERY HELPFUL PEOPLE WHO ARE JUST DONATING THERE TIME. IS THIS WHAT KEEPING THE INTERNET FREE IS ALL ABOUT ? Sure it is. Thank ALL of you.

NOTE: I navigated away from this post to copy the URL and I lost my entire post and had to start over.
Also, it is not easy to find my own posts once I logon- if they do NOT have new comments.
It is really helpful to have a PREVIEW option.

Last edited by Corona688; 03-04-2014 at 06:20 PM.. Reason: removing broken size tags
# 2  
Old 03-12-2014
Usually, on UNIX and friends like apple, the directory permissions may prevent your ID/Group from creating files. open(2): open/possibly create file/device - Linux man page
EACCES The requested access to the file is not allowed, or search permission is denied for one of the directories in the path prefix of pathname, or the file did not exist yet and write access to the parent directory is not allowed. (See also path_resolution(7).) path_resolution(7) - Linux man page
# 3  
Old 03-17-2014
Thanks for taking the time to reply. Yes, That was the problem. I had to allow permissions on the file at all levels. I am really Sorry about the late response. I ended up locking myself out of phpMyAdmin (MySQL) and that became a priority.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to create all files generated in a directory with 644 permissions?

Hi, We are using AIX machines. How to create all files generated in a directory with 644 permissions automatically. Regards, Suresh (11 Replies)
Discussion started by: suresh3566
11 Replies

2. Shell Programming and Scripting

Mac. PHP fopen() does not create a file. Permissions.

5Thank you to those who responded. After a crazy amount of troubleshooting and getting hints and feedback from others, I was so darn determined to get on with my tutorials and I found the solution myself. Keyword search: php and 'Mac computer' and fopen and chmod. Using:php and Mac and... (1 Reply)
Discussion started by: iHaveAQuestion
1 Replies

3. HP-UX

How to create a user in UNIX with some limited permissions?

As i know, Unix or Linux only manages 2 type of user: root user or normal user. All users with userID=0 will have all administration permissions like root user with the system. In my case, i want to create a new user in HP-UNIX environment with all root permissions only one exception that this... (5 Replies)
Discussion started by: hieucn1404
5 Replies

4. Shell Programming and Scripting

Create duplicate directories with same permissions

Hi all, I need to create duplicate directories and sub directories (only the directories not the files or file contents) with the same permissions. Can some one guide me in doing this. I could able to create but here the permissions should be the same how can i do this in linux. Thanks in... (5 Replies)
Discussion started by: Olivia
5 Replies

5. Shell Programming and Scripting

Get password protected URL folder using PHP fopen function

Hi everybody, Please some help over here, I`m pretty new in PHP. I have a cronrefresh php file within a website, I need this script get infornation from a URL of the site. Part of the script where $URL variable appears is: $fdURL = mysql_query("SELECT * FROM affiliSt_config WHERE name... (2 Replies)
Discussion started by: cgkmal
2 Replies

6. Shell Programming and Scripting

permissions to create log file from script

hi all, have a script which i am using to generate a log file. i use "touch out.log" command to create the file and later on i want to echo lines to this file. for some reason it keeps giving me this error when i try and create the file ; touch: out.log cannot create i have... (3 Replies)
Discussion started by: cesarNZ
3 Replies

7. UNIX for Dummies Questions & Answers

How to create new users on my mac from the terminal

I finally got how to su - in my mac from the terminal. Now I would like to be able to add new users. useradd -m -d ..... doesn't seem to work. (1 Reply)
Discussion started by: bigmac18
1 Replies

8. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies

9. Programming

Mac OS X - open() and fopen() with French filename

Hi I was trying to open a file with french name on Mac OS-X with open() and fopen() but it didn't work.Do we have any POSIX unix func. which can be used to open any file with special name. if anybody has an idea plz help. Thanks Mohit (1 Reply)
Discussion started by: mohit grover
1 Replies

10. UNIX for Dummies Questions & Answers

File Permissions in Mac OS X

On my Mac OS X machine, I would like to edit the httpd.conf Apache configuration file. When I open the file up in TextEdit or even VI, I get an error that there was an error saving the file. I tried "su root" and that still does not work. I heard that the "chown" command can change the file... (11 Replies)
Discussion started by: liveapple2000
11 Replies
Login or Register to Ask a Question