I have a AS3 flash app that needs to create a folder/path (online) for each user, and get some xml files inside these folders.
I can get the php to write these xml files, but only if the path/folder already exists. If it doesen’t, then it returns an error:
[<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /home/edicoes/public_html/test//savexml.php on line 20
Here is the php code:
<?php
$XMLFile = $_POST["xmlfile"];
$filename = $_POST["filename"];
//mkdir($User, '0777'); //I tried mkdir, to no avail. It's only for offline?
$handle = fopen($filename, 'w+');
fwrite($handle, $XMLFile );
fclose($handle);
echo "result=success";
?>
You just have to create the directory first. Make sure apache have the rights to create dir in parent dir (chmod 777).
What if someone call your code with :
xmlfile = malicious php code
filename = something.php
and then call the php page with a browser ?
You should care about security, at least add the “.xml” extension in php code.