User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,851 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,743 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 247 | Replies: 1 | Solved
Reply
Join Date: Dec 2007
Location: Oklahoma
Posts: 161
Reputation: ProfessorPC is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 16
ProfessorPC ProfessorPC is offline Offline
Junior Poster

Image in xml

  #1  
May 14th, 2008
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!";
}
?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Location: Oklahoma
Posts: 161
Reputation: ProfessorPC is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 16
ProfessorPC ProfessorPC is offline Offline
Junior Poster

Re: Image in xml

  #2  
May 16th, 2008
ok i found a solution to my problem. $row['image'] is my image location.
$xml_doc .= "<image>";
$xml_doc .= base64_encode(file_get_contents ( "$row['image']" ));
$xml_doc .= "</image>";
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC