You are here: Re: Creating files using fopen that are unlocked! « PHP Programming Language « IT news, forums, messages
Re: Creating files using fopen that are unlocked!

Posted by Malcolm Dew-Jones on 11/09/14 11:26

monomaniac21 (marcrice20@msn.com) wrote:
: Hi everyone

: i'm trying to setup my website to create new webpages dynamically using
: php but I am have a major problem in that whenever i create a file it
: is always created locked so that it can only be read even when i
: specify read and write access.

: Here is a basic example of the code I am using (I am using a Mac OSX
: 10.3.9):

: <?php

: $filename = '/Users/myusername/sites/mysitefolder/newfile.php';
: $mytext = 'my text';

: fopen($filename, 'w+');
: fwrite($filename, $mytext);
: fclose($filename);

: ?>

: When i run this program all it does is create a blank file with
: read-only access. My question is what settings do I need to change that
: will enable me to create writable files using PHP?

RTFM for fopen, chmod, and umask.

"Access" controls who can do what operations on the file.

"Mode" tells the open command what your program wants to do right now (and
the "access" controls if you will be allowed to do it).

'w+' does not create a file with write _access_, it opens a file _handle_
in read/write _mode_.

It is perfectly possible to open (and thereby create) a new file using a
file handle in write _mode_, but for the file thus created to have read
only access permissions.

--

This programmer available for rent.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация