PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 8th, 2013, 12:12 PM
TomL in VA TomL in VA is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 TomL in VA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 37 sec
Reputation Power: 0
How to read pdf/doc/excel data from a php variable

Is there a way to read a pdf/doc/excel data where the data resides in a variable? The data in question comes from email attachments I have been able to open, which is separate from the email content. I also have the content type, which tells me if the attachment is a pdf, doc file, excel etc.

I put the attachment content(data) into an array variable with the content type and the original file name of the email that the data was attached to. The question is, is there a way to read the pdf/doc/excel files directly from the php variable? The best I have been able to do is to create a file, load the file with the variable(data) and then open the file. This works fine except now I'm stuck with a new file, which I don't need. I tried to unlink the file after the read, but the file does not get deleted.

Thanks,
Tom

//Table array 0= filename, 1 = data, 2 = content type
$TableArray = $_POST['TableArray'];
$i = $_POST['submit']; // tells me which attachment to read
$ContentType = "Content-Type: " . $TableArray[$i][2];
header($ContentType);
$save_dir = "/tmp/";
if ($fp = fopen($save_dir.$TableArray[$i][0], 'w'))
{
fwrite($fp,$TableArray[$i][1]); // load the file with data
fclose($fp);
}
readfile($TableArray[$i][0]); // read and display the file
unlink($TableArray[$i][0]); // file is still present??

Reply With Quote
  #2  
Old January 8th, 2013, 12:25 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,907 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Month 1 Day 2 h 18 m 32 sec
Reputation Power: 581
Rather than try to read the mail manually and putting it into a variable, can you use the PHP imap functions?
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old January 8th, 2013, 12:32 PM
TomL in VA TomL in VA is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 TomL in VA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 37 sec
Reputation Power: 0
I would if I could

Quote:
Originally Posted by gw1500se
Rather than try to read the mail manually and putting it into a variable, can you use the PHP imap functions?


Unfortunately I don't have access to the imap functions, which is why I ended up with the attachments in variables.

Thanks,
Tom

Reply With Quote
  #4  
Old January 8th, 2013, 12:59 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,907 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Month 1 Day 2 h 18 m 32 sec
Reputation Power: 581
Maybe this this will help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How to read pdf/doc/excel data from a php variable

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap