How to convert urls to docs

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
ngprasad
Forum Newbie
Posts: 2
Joined: Wed Mar 19, 2008 12:33 pm

How to convert urls to docs

Post by ngprasad »

I am unable to fix this task.Can you please help me.

It is working only for text data.But, not working for webpage content.

For text data, Can you please check it in

http://www.celltonet.com/urltodoc4.php

Enter these urls http://www.php.net , http://www.microsoft.com[I am using comma seperator between urls.] in text box and click on "Create Doc".

For webpage,Can you please check it in

http://www.celltonet.com/urltodoc.php

If i enter these urls http://www.php.net , http://www.microsoft.com in text box and click on "Create Doc".I am receving content for first url only i.e http://www.php.net But, i am not getting second page content.

How to display second page conetent in doc file?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: How to convert urls to docs

Post by Zoxive »

This post is essentially useless without showing the code that is creating the docs, and grabbing the data.

Pointing out what does what, and what you are having problems with and what you have tried.
ngprasad
Forum Newbie
Posts: 2
Joined: Wed Mar 19, 2008 12:33 pm

Re: How to convert urls to docs

Post by ngprasad »

My code is

$str1=trim($_REQUEST['urls']);
$str=explode(",",$str1);
for($i=0;$i<count($str);$i++) {
$handle = fopen(trim($str[$i]), "r");
$content= stream_get_contents($handle);
$myarray[]=$content;
fclose($handle);
}
$mystring = implode("\x0C", $myarray);
file_put_contents("urltodoc.doc",$mystring);
header('Content-type: application/msword');
header('Content-Disposition: attachment; filename="urltodoc.doc"');
readfile('urltodoc.doc');
Post Reply