Often these things are related to the string you are using for pathname, have you echo'd (printed) it to screen and checked? perhaps you missed off the leading / for example?

James

At 13:27 25/08/2006, you wrote:

Paul,

What is error reporting set at? What errors are you receiving?
Tack on phpinfo() at the end of the script.
It's possible PHP is trying to create the file where you do not have permission to do so, you may have to build up the path from docroot.

HTH -Miles

At 05:15 AM 8/25/2006, Paul Steven wrote:

Anyone have a working example of a PHP script to create a text file using
PHP?

I am trying to get the following to work but it is not creating the text
file on my server. I have set the permissions of the folder to 777 which
should in theory allow a file to be created.

Thanks

Paul

<?php
// the name of the text file
$filename = 'test3.txt';

// hard code the variable from flash
$somecontent = "Add this to the file\n";

// If the file doesn't exist, attempt to create it
// and open it for writing
// anything already writen will be replaced
if (!$handle = fopen($filename, 'w')) {
        echo "&message=Cannot open file&";
        exit;
}

// Write $somecontent to the opened file.
if (fwrite($handle, $somecontent) === FALSE) {
        echo "&message=Cannot write to file&";
        exit;
}
// close the file
fclose($handle);

// send the variable to flash
echo "&message=$somecontent&";

?>

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/427 - Release Date: 8/24/2006


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to