Lets say that in my flash project I have script that create for me xml files dynamically (by PHP). XML file name is based on specific variable and escaped using escape(variable) in case that variable may (and mostly do) contains unsupported filename chars…
I need to know precise name of xml file later in my flash project, because I’m loading these XML files only if unescape(XMLfile) == variable . There’s a lot of variables, so I can’t just use String.replace() function to wipe out unsuported fileneme chars…
There’s part of PHP file I’m using:
$XMLDom = new DomDocument('1.0', 'UTF-8');
$xmlId = trim($_POST['xmlId']);
if(file_exists($xmlId)){
$XMLDom ->load($xmlId);
}else{
$newXMLHandler = fopen($xmlId, 'w') or die("can't open file");
fclose($newXMLHandler);
$XMLDom ->load($xmlId);
.... rest of the code ....
$XMLDom ->save($xmlId);
}
The result of the code above is that in directory are 2 newly created XML files
One XML empty created by fopen($xmlId, 'w'), named: “fi%20le%2C%2E%40.xml”
and second one named: “fi le,.@.xml” where all my new XML data is stored…
Is there any way to load escaped named XML file by PHP?
Thanks in advance.
Arthur.
I don’t feel quite confident I understand your problem, but if your question was to find the analogue function to escape() in PHP, then
urlencode()looks like the best match, but you need to research what exactly is being escaped. Note, for example, that there are several different ways to percent-encode strings, especially the multibyte strings. Flash may useescapeMultibyte()or it can also useencodeURIComponent()both encode different subsets of characters, and differently – so beware!Now, regarding file names, if your HTTP server is running on Unix system, than “fi le,.@.xml” is a valid file name, nothing to worry about – inconvenient some times, but it is a legitimate name.
would create a file, no problems there. Basically, the restricted characters are the slashes and the null character (“\x00”), but it is common to restrict also the characters that may be interpreted as shell commands – this is really up to you.