Click to See Complete Forum and Search --> : File creation with PHP under Win2000?


Anon
05-11-2001, 08:29 AM
Hi, all:

What do I need to do to let PHP create files on the webserver? I am making a knowledge base and I want to be able to add files through a PHP page instead of having to do it manually.

Do I need to create a user that has permissions to create/edit files on the server and then set the script to run as that user?

Thanks.

Anon
05-15-2001, 04:51 AM
Try this:

$fp = fopen("./directory/filename.extension", "w+");
fputs($fp, "---data---");
fclose($fp);

Of course, you should check if the file exists BEFORE creating it. If you don't, you could lose an important file... Use the function file_exists (http://www.php.net/manual/en/function.file-exists.php) Replace ---data--- by your data.

Hub. Lem.

Anon
05-15-2001, 12:24 PM
Yucateco wrote:
-------------------------------
Try this:

$fp = fopen("./directory/filename.extension", "w+");
fputs($fp, "---data---");
fclose($fp);

Of course, you should check if the file exists BEFORE creating it. If you don't, you could lose an important file... Use the function file_exists (http://www.php.net/manual/en/function.file-exists.php) Replace ---data--- by your data.

Hub. Lem.
-----------

Two problems:
1) I am using windows 2000, so I have to use:
$fp = fopen("<path>", "wb");

2) THAT is the line that causes an error. The preprocessor prints "Permission denied in <path\script> on line 64"

Because of this error, I am assuming I have missed a setting in IIS, or that the permissions on the script are wrong. What do I have to do to give the script permissions under IIS to add and edit files on the web server?

Anon
05-15-2001, 12:41 PM
I don't know IIS, but under Apache, what I wrote works perfectly.

A good advice: install Apache...

Hub. Lem.

Anon
07-18-2002, 11:21 AM
I have the same problem, tried to set
permissions in IIS to everyone/ALL.
This does not seem to solve the problem.
Perhaps something in the PHP config files
that we must change? ANYONE with solution
or ideas please let me know, szuccaro@gmprt.com !!!