Filename from file_get_contents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

Filename from file_get_contents

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Filename from file_get_contents

Post 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.
Post Reply