Hello
I have been working on this script for a little while. All is working good(get all information into the xml). But I am needing to have the php code add an image to the xml for download. If anybody as any ideas i would greatly appreciate it.

I have this pulling testing info from the MYSQL db. There will be an image that will need to be added to this document.

if(isset($_POST['file_name'])) {
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$rootElementStart = "<user>";
$rootElementEnd = "</user>";
$xml_doc = $xml_dec;
$xmlfilename = $_POST['file_name'];
$userinfo = mysql_query("select userid, firstname, lastname, email from users") or die(mysql_error());
while($row = mysql_fetch_array($userinfo))
{
$xml_doc .= $rootElementStart;
$xml_doc .= "<id>";
$xml_doc .= $row['userid'];
$xml_doc .= "</id>";
$xml_doc .= "<name>";
$xml_doc .= $row['firstname']." ".$row['lastname'];
$xml_doc .= "</name>";
$xml_doc .= "<email>";
$xml_doc .= $row['email'];
$xml_doc .= "</email>";
$xml_doc .=$rootElementEnd;
}
$default_dir = "testing/";
$default_dir .= $xmlfilename.".xml";
$fp = fopen($default_dir,'w');
$write = fwrite($fp,$xml_doc);
//header($default_dir);
echo $default_dir;
echo "Document has been written successfully!";
}
?>

ok i found a solution to my problem. $row is my image location.

$xml_doc .= "<image>";
$xml_doc .= base64_encode(file_get_contents ( "$row['image']" ));
$xml_doc .= "</image>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.