fopen - 追加工作,写入失败(但文件被截断) [英] fopen - append works, write fails (but file is truncated)

查看:113
本文介绍了fopen - 追加工作,写入失败(但文件被截断)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试写入当前目录中的文件 - 没有远程

文件。主题说明了一切 - 我可以添加目录

和文件是可写字的。这发生在挪威的一个(相当不错的)免费的

主机上,它没有使用安全模式,运行PHP 5.1.6作为

下面的PHP信息显示.. 。


测试时间:
http://home.no.net/moldevbk/fopen-test/?mode=w (写 - 失败)
http://home.no.net/moldevbk/fopen-test/?mode=a (追加 - 确定)
http:/ /home.no.net/moldevbk/fopen-test/p.php - PHP信息
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - 测试脚本的源代码。


我搜索了网络和usenet,但没有发现这个问题

之前提到过。我确实知道我可以解决这个问题,因为

首先截断文件然后附加到空文件 - 但是

这个丑陋的... ... >

问候,汉斯

-

+它是GNU / Linux,而不是Linux - http://www.gnu.org/gnu/linux-and-gnu.html

+支持自由软件基金会 - http://member.fsf .org /

+成为开放目录项目编辑 - http: //dmoz.org/

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/

推荐答案

7月27日中午12点,Hans Fredrik Nordhaug< han ... @ gmail.comwrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:

我正在尝试写入当前目录中的文件 - 没有远程

文件。主题说明了一切 - 我可以添加目录

和文件是可写字的。这发生在挪威的一个(相当不错的)免费的

主机上,它没有使用安全模式,运行PHP 5.1.6作为

下面的PHP信息显示.. 。


测试时间: http://home.no.net/moldevbk/fopen-test/?mode=w(写入 - 失败) http://home.no.net/moldevbk/fopen-test/?mode=a(追加) - 好的) http://home.no.net/ moldevbk / fopen-test / p.p​​hp- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-测试脚本的源代码。

我搜索了网络和usenet,但没有发现这个问题

之前提到过。我确实意识到我可以通过

来解决这个问题首先提交文件,然后附加到空文件 - 但是

这个很难看...


问候,汉斯


-

+这是GNU / Linux,不是Linux - > http://www.gnu.org/ gnu / linux-and-gnu.html

+支持自由软件基金会 - > http://member.fsf.org/

+成为开放目录项目编辑器 - > http://dmoz.org/
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/



只是好奇如果不使用fopen w为模式使用WB?我不确定这是否有所不同,但可能会成功

工作。

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.

7月27日下午12:19,davidkru ... @ techie.com写道:
On Jul 27, 12:19 pm, davidkru...@techie.com wrote:

7月27日中午12点,Hans Fredrik Nordhaug< han ... @ gmail.comwrote:


On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:



我正在尝试写入当前目录中的文件 - 没有远程

文件。主题说明了一切 - 我可以添加目录

和文件是可写字的。这发生在挪威的一个(相当不错的)免费的

主机上,它没有使用安全模式,运行PHP 5.1.6作为

下面的PHP信息显示.. 。
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 ...


测试时间: http://home.no.net/moldevbk/fopen-test/?mode=w(write- failed) 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测试脚本。
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.


我搜索了网络和usenet,但没有发现这个问题

之前提到过。我做的意识到我可以通过

来解决这个问题首先截断文件,然后附加到空文件 - 但是

丑陋... ...
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 ...


问候, Hans
Regards, Hans


-

+它是GNU / Linux,而不是Linux - > http://www.gnu.org/gnu/linux-and-gnu.html

+支持自由软件基金会 - > http: //member.fsf.org/

+成为开放目录项目编辑器 - > http://dmoz.org/



只是好奇是不是使用wb为模式发送fopen w?我不确定这是否会产生任何影响,但可能会成功。

work.-隐藏引用的文字 -


- 显示引用的文字 -


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 -



如果你将试图保存的文件夹的权限设置为

到chmod 707你应该能够写这个文件。

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.


7月27日中午12点,Hans Fredrik Nordhaug< han ... @ gmail.comwrote:
On Jul 27, 12:00 pm, Hans Fredrik Nordhaug <han...@gmail.comwrote:

我正在尝试写入当前目录中的文件 - 没有远程

文件。主题说明了一切 - 我可以添加目录

和文件是可写字的。这发生在挪威的一个(相当不错的)免费的

主机上,它没有使用安全模式,运行PHP 5.1.6作为

下面的PHP信息显示.. 。


测试时间: http://home.no.net/moldevbk/fopen-test/?mode=w(写入 - 失败) http://home.no.net/moldevbk/fopen-test/?mode=a(追加) - 好的) http://home.no.net/ moldevbk / fopen-test / p.p​​hp- PHP infohttp://home.no.net/moldevbk/fopen-test/fopen-test.phps-测试脚本的源代码。

我搜索了网络和usenet,但没有发现这个问题

之前提到过。我确实意识到我可以通过

来解决这个问题首先提交文件,然后附加到空文件 - 但是

这个很难看...


问候,汉斯


-

+这是GNU / Linux,不是Linux - > http://www.gnu.org/ gnu / linux-and-gnu.html

+支持自由软件基金会 - > http://member.fsf.org/

+成为开放目录项目编辑器 - > http://dmoz.org/
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/



确保将目录设置为允许使用权限进行组写

设置为707.然后它允许它工作。

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


这篇关于fopen - 追加工作,写入失败(但文件被截断)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆