473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
16 4645
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin Lucas-Smith | last post by:
I wrote the function below as part of a larger class. The fopen stage works, and, as according to the documentation at www.php.net/fopen that succesfully creates a new file. The fwrite stage...
2
by: Loopy | last post by:
I'm trying to write a script that will connect to an external site so that I can get access referer information in a database on another one of my sites. I got errors, so I tried to write a script...
1
by: bissatch | last post by:
Hi, I am currently working on a content management system where a user can fill in a form (title, keywords, link text etc. - all the initial attibutes), which when submitted, will go onto create...
5
by: Arturo Ordaz | last post by:
Has anyone run into documentation that describes how fopen(log_file, "a") behaves when it is potentialy used (called/referenced) 1000's of times an hour on a single resource file? I am trying to...
14
by: Aaron Couts | last post by:
I have a program that writes to a log file. It's compiled on RH Linux 7.3 (Kernel 2.4.18-18.7). It's using fopen in append mode. When the file reaches 51200000 bytes in size, the program will no...
3
by: Michael | last post by:
I'm having trouble opening a file for writing under Red Hat Fedora Linux. Here is the statement: $fp = fopen("/var/www/html/test01.txt","w"); It generates the following error msg: ...
10
by: Julia | last post by:
Hi, there, I am trying to append a binary file by using: FILE *strean; stream = fopen( "c:\temp.dat", "ba+" )); Is there a way that I can check if the file exists or not before fopen,...
20
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code...
31
by: Bill Cunningham | last post by:
Is there a real difference in r+ and w+ ? I read in my man pages that r+ opened a file for reading and writing while w+ opened a file for reading and writing and if the file didn't exist it would...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.