downloading a php web page to a doc file

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
shivali_chandra
Forum Newbie
Posts: 1
Joined: Tue Oct 26, 2010 5:41 am

downloading a php web page to a doc file

Post by shivali_chandra »

I have problem that when i click to download the contents of a web page to a .doc file only text is getting stored but not images and graphs.The code for that is below.

Code: Select all

<?php 
$fileName = $_GET['urlid']; 
header("Content-Type: application/vnd.ms-word"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("content-disposition: attachment;filename=$filename");
readfile("Report/$filename");
print_r($filename);
?> 
Please help to get the images also stored in .doc file
Last edited by Benjamin on Tue Oct 26, 2010 6:30 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: downloading a php web page to a doc file

Post by yacahuma »

can you compare the byte size of both documents? SAll you are doing is downloading whatever you have in your server, so they must be the same size. The is nothing in php to give you or not images, so I think you are looking in the wrong place.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: downloading a php web page to a doc file

Post by twinedev »

When you call a web page, it consists of nothing but the file you call. It is up to the browser (ie your script) to then read and parse the document and figure what other files to read from the servers.

Parse the <img> tags looking for src="XXXXX" and then get each of those as well.
Many sites now use images in the background, so you have to parse the styles, and look for called style sheets (and called style sheets within those called style sheets...)

Now if you are needing the word document to LOOK like you would see it in the browser, well then that is a whole other challenge there, and you are best off looking for a 3rd party script/program to do that for you.

It can get complicated.

-Greg
Post Reply