Jump to content

[SOLVED] file_get_contents help


sasori

Recommended Posts

i don't get how to use the file_get_contents function, my code produces error :(

 

<?php

$dir = ftp_connect("www.yourdomain.com");
$user = "username";
$pwd  = "password";
$login = ftp_login($dir,$user,$pwd);
$filesarray = ftp_nlist($dir,"www/");
$fh = fopen('http://www.yourdomain.com/marry_poppins.html','r') or die ("can't open file");
while(!feof($fh))
{
$readline = file_get_contents($fh);	
echo $readline;
}
ftp_close($dir);
fclose($fh);
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/117829-solved-file_get_contents-help/
Share on other sites

fopen opens a resource stream. You would use fread to read the contents and fwrite to write the contents.  file_get_contents requires the actual file name and it reads the file into a giant string of the file's contents, so you don't really use file_get_contents with fopen. You'd really be using one or the other.

fopen opens a resource stream. You would use fread to read the contents and fwrite to write the contents.  file_get_contents requires the actual file name and it reads the file into a giant string of the file's contents, so you don't really use file_get_contents with fopen. You'd really be using one or the other.

 

it works fine now..thanks

 

<?php

$dir = ftp_connect("domain.test.org");
$user = "user";
$pwd  = "password";
$login = ftp_login($dir,$user,$pwd);
$filesarray = ftp_nlist($dir,"www/");
$fh = file_get_contents('http://www.domain.com/marry_poppins.html');
echo $fh;
ftp_close($dir);
fclose($fh);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.