Forum Moderators: coopster

Message Too Old, No Replies

creating a file using php

         

testy

1:16 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



Hi,

Hope I get the help here.

After spending the whole day, I am still blinking?

I want to dynamically create files.
Intially I tried fopen. But I had permission errors.

I tried ftp. Using that I was able to create directories but not new files.

Please some one help me.

jpl80

2:12 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



try this command from the shell

ls -l

that should tell you what your permissions are.

you can change your permissions using the command chmod.

If you get confused, search the web for these unix/linux commands, ls and chmod.

there should be plenty of info there.

jpl80

2:19 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



also, This is some code I've used in the past that creates and writes to a file


<?
// writes to file
$path = "../surveys/xml/$fn";
if (!$handle = fopen($path,"w")) {
echo "Cannot open file ($fn)";
exit;
}
if (fwrite($handle, $p) === FALSE) {
echo "Cannot write to file ($fn)";
exit;
}
echo $p;
fclose($handle);
?>

testy

4:00 am on Nov 23, 2005 (gmt 0)

10+ Year Member



Yes I know the basics. I tried them all.

What I really want is to create a file with out changing the directory permissions (chmod). Can we authenticate as a user and then create it using php.

I am trying yo do it in a hosted apache server in linux.
All fopen kind of things work fine with my localhost.

henry0

3:55 pm on Nov 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Regardless of the Dir permission
this calls for a higher level of permission
to create a file on the fly you need to verify with your ISP who has file ownership.

In most shared server environmentyou won't be able to do it.

henry0

10:19 pm on Nov 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition a few ISP do offer an in between package
less expensive than a dedicated server
But where you own your PHP.

testy

5:02 am on Nov 24, 2005 (gmt 0)

10+ Year Member



I found the real problem I had.

It was safe mode issue.