jmurch Posted April 10, 2007 Share Posted April 10, 2007 I posted this yesterday and it's starting to look like I'm stuck with the non-elegant solution. I'm posting this one last time hoping that someone has had a similar problem and found a non-work around solution: I am using the following to generate an xml doc to the users browser: $fp = fopen("document.xml", 'w+'); $str = ($xml_frame->Fields('top_xml').$content->Fields('xml').$content->Fields('xml').$xml_frame->Fields('bottom_xml')); fwrite($fp, $str); fclose($fp); header( 'Location: http://www.website.com/document.xml') ; I would like to delete 'document.xml' after it has been loaded to the user's browser. Unlinking the file kills it before it loads and sleep hangs everything. I there a way to detect when it's finished downloading to the user? Thanks Re: help!! there must be a way.. « Reply #1 on: Yesterday at 08:31:04 PM » Quote -------------------------------------------------------------------------------- A standard method is: 1. Generate a random name for each generated document 2. Store them all in one directory 3. Have a script run regularly that checks for old files (using fstat()) and deletes anything older than a fixed limit, say 1 hour. You can run the script from cron, or have it run each time a user accesses a particular script. That doesn't detect when the file is downloaded, because that's a very difficult task. Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/ Share on other sites More sharing options...
utexas_pjm Posted April 10, 2007 Share Posted April 10, 2007 Don't write the files to your disk. Just push the XML output to the browser using a print/echo statement. Best, Patrick Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225863 Share on other sites More sharing options...
jmurch Posted April 10, 2007 Author Share Posted April 10, 2007 Patrick, That's what I originally did but I need to send the files to the user's browser with .xml extension and do not know how to do that. If I just echo the files they dont get handled by the application that's associated with that xml tag <?mso-application>. If I can echo the content as alias filename rather than the php filename that would be a perfect solution. Jeff Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225872 Share on other sites More sharing options...
monk.e.boy Posted April 10, 2007 Share Posted April 10, 2007 You'll have to change the header type using: http://uk3.php.net/header, use Live HTTP Headers to see what the correct XML header stuff is, then echo '<xml>'; monk.e.boy Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225874 Share on other sites More sharing options...
monk.e.boy Posted April 10, 2007 Share Posted April 10, 2007 If I can echo the content as alias filename rather than the php filename that would be a perfect solution. Jeff Try using apache rewrite rules to change http://www.me.com/my-xml.xml to pass over to your php file. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225878 Share on other sites More sharing options...
utexas_pjm Posted April 10, 2007 Share Posted April 10, 2007 You need to tell the browser that you're sending an xml document. You can do that by using the header function: <?php header('Content-type: text/xml'); ?> Best, Patrick Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225881 Share on other sites More sharing options...
jmurch Posted April 10, 2007 Author Share Posted April 10, 2007 Thanks guys! As always this forum is awesome. Jeff Link to comment https://forums.phpfreaks.com/topic/46437-solved-no-better-way/#findComment-225884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.