Welcome Guest, Not a member yet? Register   Sign In
[Solved] creating xml file and pass it to flash?
#1

[eluser]Zeeshan Rasool[/eluser]
Hi friends,
I need a little help, i want to create an xml file which i have to pass to a flash but i did'nt know how to create xml ?
Currently im getting data in controller and trying to write file that is in main root folder
Code:
function xml()
{
if($page=='er')
{
$data['images_title'] = $this->Admin_gallery->executive();
}
elseif($page=='lv')
{
$data['images_title'] = $this->Admin_gallery->luxury();
}
    
$stringData = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$stringData .= "<gallery>\n";
foreach($data['images_title'] as $rec)
{

$stringData .= "<image picture=\"".$rec->image_path."\" lab=\"".$rec->image_title."\"></image>\n";
}
$stringData .= "</gallery>\n";
$stringData .= "<filePath path=\"".base_url().'site/'."images/\"></filePath>\n";        
        
$myFile = "http://localhost/mysite/flash_param_file.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
//$stringData = "Floppy Jalopy\n";
fwrite($fh, $stringData);
fclose($fh);
}

I have created a blank File on main root folder but error is "can't open file"

Did you know any other solution
I just need a xml file printed my data

Thanks in advance
#2

[eluser]sudesh[/eluser]
Did u check the file is created.

I m not an expert on xml, so i don't now whether it is correct.

to open file like this http://localhost/mysite/flash_param_file.xml using url u need allow_url_fopen = On in php.ini, and this is not considered safe

rather change the path to /home/something/somthing/mysite/flash_param_file.xml

or use getcwd()."/".flash_param_file.xml

this should work fine.
#3

[eluser]Zeeshan Rasool[/eluser]
its ok now,
I was doing it with PHP func like write(). But now im using file_write() of CI function. And its working well now.




Theme © iAndrew 2016 - Forum software by © MyBB