Page 1 of 1

Filename from file_get_contents

Posted: Thu Jan 14, 2010 2:16 am
by paqman
Hey guys,

I've got a php script using the Pear Excel Spreadsheet writer to output an excel spreadsheet (go to the page and you download an excel file) - that works just fine. I'm also running a cron job nightly, which runs a php script to do nightly mainteance and other things - one of these other things I'd like to add in is automatically emailing the excel file generated by that first script. I've got that working as well, but only by using file_get_contents as I have to read from a url, not a file on the server.

So, my question - how can I get the filename out of file_get_contents, or is that impossible? Pear is setting the spreadsheet's name (based on the information in it) and I don't have access to that anymore (have to make up another name when I'm emailing). Would it be best to have Pear save the excel spreadsheet on the server, then use fopen to grab and email that file instead?

Thanks

Re: Filename from file_get_contents

Posted: Thu Jan 14, 2010 2:37 am
by requinix
paqman wrote:how can I get the filename out of file_get_contents
What filename? You mean the spreadsheet name that the PEAR extension created?
Yeah: you'd have to save the file, open it, grab the name, close it, and send your email.

Sounds to me like you could use a redesign. Move the Excel-file-generation code someplace neutral then make the download script and maintenance script use it separately.