Page 1 of 1

downloading a php web page to a doc file

Posted: Tue Oct 26, 2010 5:46 am
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

Re: downloading a php web page to a doc file

Posted: Tue Oct 26, 2010 7:36 am
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.

Re: downloading a php web page to a doc file

Posted: Tue Oct 26, 2010 8:41 am
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