By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

fopen - append works, write fails (but file is truncated)

P: n/a
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans
--
+ It's GNU/Linux, not Linux -http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation -http://member.fsf.org/
+ Become an Open Directory Project Editor -http://dmoz.org/
Jul 27 '07 #1
Share this Question
Share on Google+
16 Replies


P: n/a
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)http://home.no.net/moldevbk/fopen-test/p.php- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.

Jul 27 '07 #2

P: n/a
On Jul 27, 12:19 pm, davidkru...@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:


I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/

Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.- Hide quoted text -

- Show quoted text -
If you set the permissions on the folder you are attempting to save to
to chmod 707 you should be able to write the file.

Jul 27 '07 #3

P: n/a
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)http://home.no.net/moldevbk/fopen-test/p.php- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.

Jul 27 '07 #4

P: n/a
da*********@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
>I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)http://home.no.net/moldevbk/fopen-test/p.php- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/

make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.
707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 27 '07 #5

P: n/a
On Jul 27, 3:17 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
davidkru...@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.

707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
You are right 707 wouldn't be a good one to use on a production
server, but for testing purposes i think would be OK. I am thinking
that the problem is when the script runs it is setup with a group of
nobody, setting to 707 would allow that to write the file, if it were
a permission problem causing the issue, using 707 would make anyone
able to write to the folder, but would also tell for sure if the
folder permissions are the cause of the problems the OP is having.

Jul 27 '07 #6

P: n/a
On 2007-07-27, da*********@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
>I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)http://home.no.net/moldevbk/fopen-test/p.php- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/

Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.
I don't understand how that can make any difference, but I tested with
"wb" and it made no difference - try for yourself:
http://home.no.net/moldevbk/fopen-test/?mode=wb

Hans
Jul 27 '07 #7

P: n/a
On 2007-07-27, da*********@techie.com wrote:
On Jul 27, 12:19 pm, davidkru...@techie.com wrote:
>On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:


I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/

Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.- Hide quoted text -

- Show quoted text -

If you set the permissions on the folder you are attempting to save to
to chmod 707 you should be able to write the file.
The folder is already set to 777 as the URL
http://home.no.net/moldevbk/fopen-test/ tells you. How setting it to
something more restrictive will help beats me. (I did test and it of
course made no difference.)

Are you just suggesting all the standard answers in stead of reading
what I write? Thx for your time anyway.

Hans
Jul 27 '07 #8

P: n/a
On 2007-07-27, Jerry Stuckle wrote:
da*********@techie.com wrote:
>On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
>>I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source
code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/

make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.

707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.
Come on guys - as the URL http://home.no.net/moldevbk/fopen-test/
shows the execute bit isn't set for the file, only for the directory
(where it's needed). And if you pay even more attention to what I
wrote (and the URL above shows), you'll notice that
1) this is free hoster so I can't change how the groups are setup
2) you have to allow anyone (666) to write to the file because nobody
(the web server user) isn't member of the users group.

Anyway, thx for your time.

Hans
Jul 27 '07 #9

P: n/a
Hans Fredrik Nordhaug wrote:
On 2007-07-27, da*********@techie.com wrote:
>On Jul 27, 12:19 pm, davidkru...@techie.com wrote:
>>On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:

I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.- Hide quoted text -

- Show quoted text -
If you set the permissions on the folder you are attempting to save to
to chmod 707 you should be able to write the file.

The folder is already set to 777 as the URL
http://home.no.net/moldevbk/fopen-test/ tells you. How setting it to
something more restrictive will help beats me. (I did test and it of
course made no difference.)

Are you just suggesting all the standard answers in stead of reading
what I write? Thx for your time anyway.

Hans
You should set it to what's appropriate. Seldom is 777 appropriate, and
PHP may disallow access to a file or directory so set up.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 28 '07 #10

P: n/a
da*********@techie.com wrote:
On Jul 27, 3:17 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>davidkru...@techie.com wrote:
>>On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.
707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

You are right 707 wouldn't be a good one to use on a production
server, but for testing purposes i think would be OK. I am thinking
that the problem is when the script runs it is setup with a group of
nobody, setting to 707 would allow that to write the file, if it were
a permission problem causing the issue, using 707 would make anyone
able to write to the folder, but would also tell for sure if the
folder permissions are the cause of the problems the OP is having.
I would NEVER set anything up on a test server different than a
production server.

The purpose of a test server is to find problems BEFORE they occur. And
to do so, you need to emulate the production environment.

Setting different flags does NOT do this.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 28 '07 #11

P: n/a
Hans Fredrik Nordhaug wrote:
On 2007-07-27, Jerry Stuckle wrote:
>da*********@techie.com wrote:
>>On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source
code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.
707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.

Come on guys - as the URL http://home.no.net/moldevbk/fopen-test/
shows the execute bit isn't set for the file, only for the directory
(where it's needed). And if you pay even more attention to what I
wrote (and the URL above shows), you'll notice that
1) this is free hoster so I can't change how the groups are setup
2) you have to allow anyone (666) to write to the file because nobody
(the web server user) isn't member of the users group.

Anyway, thx for your time.

Hans
0) I wasn't responding to you - I was responding to David.
1) You get what you pay for. Get a decent host.
2) See 1).

You can get good hosts very inexpensively. You want free? All you're
doing is trading a monthly bill for your time.

And quite frankly, you can't buy much of my time for $3-5/mo. Or even
the $25-40/mo. I pay for vps's.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 28 '07 #12

P: n/a
On 2007-07-28, Jerry Stuckle wrote:
Hans Fredrik Nordhaug wrote:
>On 2007-07-27, Jerry Stuckle wrote:
>>da*********@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
>
Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source
code of test script.
>
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
>
Regards, Hans
>
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
make sure the directory is set to allow group writing with permissions
set to 707. then it shoudl allow it to work.

707 is NOT a good one to use. It means anyone can write to the file.
And if it's not an executable file, you shouldn't have the execute bit on.

600 is great if the webserver is going to be the only one accessing it;
Otherwise you should use 660 with the proper group settings.

Come on guys - as the URL http://home.no.net/moldevbk/fopen-test/
shows the execute bit isn't set for the file, only for the directory
(where it's needed). And if you pay even more attention to what I
wrote (and the URL above shows), you'll notice that
1) this is free hoster so I can't change how the groups are setup
2) you have to allow anyone (666) to write to the file because nobody
(the web server user) isn't member of the users group.

Anyway, thx for your time.

Hans

0) I wasn't responding to you - I was responding to David.
I'm truly sorry - I realized this after posting.
1) You get what you pay for. Get a decent host.
This host has worked well for 5 years and is decent.
I'm asking here to see if anyone has seen this type of problem before
because I expect it to be a bug in PHP.

In my view it's very strange that the file is truncated, but can't
be written to ...

Regards,
Hans
Jul 28 '07 #13

P: n/a
On 2007-07-28, Jerry Stuckle wrote:
Hans Fredrik Nordhaug wrote:
>On 2007-07-27, da*********@techie.com wrote:
>>On Jul 27, 12:19 pm, davidkru...@techie.com wrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:

I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:http://home.no.net/moldevbk/fopen-test/?mode=w(write- fails)http://home.no.net/moldevbk/fopen-test/?mode=a(append- ok)http://home.no.net/moldevbk/fopen-test/p.php-PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans
--
+ It's GNU/Linux, not Linux ->http://www.gnu.org/gnu/linux-and-gnu.html
+ Support the Free Software Foundation ->http://member.fsf.org/
+ Become an Open Directory Project Editor ->http://dmoz.org/
Just curious if instead of sending fopen w for the mode using wb? I
am not sure if that will make any difference or not, but might make it
work.- Hide quoted text -

- Show quoted text -
If you set the permissions on the folder you are attempting to save to
to chmod 707 you should be able to write the file.

The folder is already set to 777 as the URL
http://home.no.net/moldevbk/fopen-test/ tells you. How setting it to
something more restrictive will help beats me. (I did test and it of
course made no difference.)

Are you just suggesting all the standard answers in stead of reading
what I write? Thx for your time anyway.

Hans

You should set it to what's appropriate. Seldom is 777 appropriate, and
PHP may disallow access to a file or directory so set up.
But this isn't case here - 777 (or really 707) is a appropriate since
the webserver user is "nobody" which isn't part of the group users.

Hans
Jul 28 '07 #14

P: n/a
On 2007-07-27, Hans Fredrik Nordhaug wrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans
Just some additional information:

If I delete the file I'm trying to write to, fopen with w mode creates
the file (with owner "nobody") and no errors occurs after that.
Apperently PHP is able to write to the file when it's owned by
"nobody" with permission 644, but not when it's owned by the user
"moldevbk" with permission 666. This is something I would expect to
happen if safe mode was on, but it's not. Append mode works in both
situation. The file is also truncated by the write fopen call in both
situation.

What is going?

Hans

PS! I have contacted the hoster - I'll let you know if they have
some explanation/solution to the issue.
Jul 28 '07 #15

P: n/a
On Jul 28, 7:58 am, Hans Fredrik Nordhaug <han...@gmail.comwrote:
On 2007-07-27, Hans Fredrik Nordhaug wrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...
Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)
http://home.no.net/moldevbk/fopen-test/p.php- PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.
I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...
Regards, Hans

Just some additional information:

If I delete the file I'm trying to write to, fopen with w mode creates
the file (with owner "nobody") and no errors occurs after that.
Apperently PHP is able to write to the file when it's owned by
"nobody" with permission 644, but not when it's owned by the user
"moldevbk" with permission 666. This is something I would expect to
happen if safe mode was on, but it's not. Append mode works in both
situation. The file is also truncated by the write fopen call in both
situation.

What is going?

Hans

PS! I have contacted the hoster - I'll let you know if they have
some explanation/solution to the issue.
I have investigated this, and there is indeed a problem on our part.
The problem was introduced when we upgraded a web server, and is
caused by incompatibilities with some of the file servers. This does
not affect all of our users.

If you want, I can move your account to a different file server. I was
about to do this anyway, but I discovered that you reference absolute
paths in your scripts. I advise you to use relative paths or at least
build the paths from $_ENV['HOME'] or similar.

We will try to solve the problem as soon as possible.

--
Frode Nordahl

Jul 31 '07 #16

P: n/a
On 2007-07-31, fr***********@gmail.com wrote:
On Jul 28, 7:58 am, Hans Fredrik Nordhaug <han...@gmail.comwrote:
>On 2007-07-27, Hans Fredrik Nordhaug wrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w(write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a(append - ok)
http://home.no.net/moldevbk/fopen-test/p.php- PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps- source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

Just some additional information:

If I delete the file I'm trying to write to, fopen with w mode creates
the file (with owner "nobody") and no errors occurs after that.
Apperently PHP is able to write to the file when it's owned by
"nobody" with permission 644, but not when it's owned by the user
"moldevbk" with permission 666. This is something I would expect to
happen if safe mode was on, but it's not. Append mode works in both
situation. The file is also truncated by the write fopen call in both
situation.

What is going?

Hans

PS! I have contacted the hoster - I'll let you know if they have
some explanation/solution to the issue.

I have investigated this, and there is indeed a problem on our part.
The problem was introduced when we upgraded a web server, and is
caused by incompatibilities with some of the file servers. This does
not affect all of our users.
Thx for the info - I'm glad it wasn't me (or a bug in PHP).
If you want, I can move your account to a different file server. I was
about to do this anyway, but I discovered that you reference absolute
paths in your scripts. I advise you to use relative paths or at least
build the paths from $_ENV['HOME'] or similar.
Feel free to move my account - just send me an e-mail when it's done.
(If the issue is fixed this week without moving, I can wait.)

Hans

PS! I would of course prefer to use $_ENV['HOME'], but $_ENV doesn't
contain HOME because the current user is "nobody" ... The absolute
paths is set in one single file so updating is no problem.
Jul 31 '07 #17

This discussion thread is closed

Replies have been disabled for this discussion.