p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Create a file with PHP


Message #1 by concepts101@h... on Tue, 10 Sep 2002 09:39:27
Hello,
How can I create a file with my code? The books say that fopen
(filename, "w") will attempt to open "filename" for writing, and if it 
does not exist to create it. My error says that "filename" can't be opened 
with no mention or way for me to know why it does not create the file. Is 
there a way to force the file to be created? I realize that I can just 
create the file myself with ftp and write to it, but what I want the 
program to do is create files named by form input.
Thanks,
Dave 
Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 10 Sep 2002 09:00:57 -0700
> How can I create a file with my code? The books say that fopen
> (filename, "w") will attempt to open "filename" for writing, and if it
> does not exist to create it. My error says that "filename" can't
> be opened
> with no mention or way for me to know why it does not create the file.


Does the webserver user have permission to write in the directory you're
trying to create the file in?  If the file already exists, does it have
permission to write to the file?

What's the exact error text?

> Is there a way to force the file to be created? I realize that
> I can just create the file myself with ftp and write to it, but
> what I want the program to do is create files named by form input.

fopen(), fwrite(), and fclose() will do the trick for you once you figure
out why fopen() is failing...

Message #3 by concepts101@h... on Thu, 12 Sep 2002 02:01:56
>Thanks Nik,
It was a simple permission problem.

 
> How can I create a file with my code? The books say that fopen
> (filename, "w") will attempt to open "filename" for writing, and if it
> does not exist to create it. My error says that "filename" can't
> be opened
> with no mention or way for me to know why it does not create the file.


Does the webserver user have permission to write in the directory you're
trying to create the file in?  If the file already exists, does it have
permission to write to the file?

What's the exact error text?

> Is there a way to force the file to be created? I realize that
> I can just create the file myself with ftp and write to it, but
> what I want the program to do is create files named by form input.

fopen(), fwrite(), and fclose() will do the trick for you once you figure
out why fopen() is failing...


  Return to Index