Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

php for windows, make a writeable file

create
a file named
data$datetime

where datetime is the current datetime

and make the file 777  writable in windows
Avatar of flubbard
flubbard

I'm a little confused.  777 would be a linux type structure.  To make it writable in windows, make sure the appropriate user permissions are set for the folders.  Is this a samba share?

 - flub
Avatar of Mark Brady
777 and any other permission settings are universal so once you set the permissions for that folder it will be writable by all platforms.
Correct, but is the file sitting on a linux box or windows box?

  flub
Avatar of rgb192

ASKER

windows server 2008

I just want to make it writable
So change the folder settings as stated above and your scripts will be able to upload and write to it.
Avatar of rgb192

ASKER

i would like to create a  new writable file using php
Ok here is how to create the new file.

$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); // this lets you open the file in write mode
// write to the file here.....
fclose($ourFileHandle); // closes the file.

Here's another example with some data written to the file.

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData); // write to the file
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData); // write more to the file
fclose($fh);

The file contents above will look like this when opened:

Bobby Bopper
Tracy Tanner

They are on separate lines because we added the "\n switch to the end of the $stringData to create a new line. Hope this helps.
Avatar of rgb192

ASKER

works to create a file and write data to file

but how to create a filename with a datetime
ASKER CERTIFIED SOLUTION
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks