GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Guru - need ur help (https://gfy.com/showthread.php?t=771905)

qw12er 09-26-2007 05:57 AM

PHP Guru - need ur help
 
I want to "Download' a file from a remote server with a PHP script.

I used this function below, but I need to enable the remote file opening option in php.ini to make it work. Let's say that I can't turn on this option for some reason. What else can I do to avoid this problem ? Is FTP functions my answer ?

Thanks

function download($file_source , $file_target) {
$rh = fopen ($file_source, 'rb');
$wh = fopen($file_target, 'wb' );
if ($rh===false || $wh=== false) {
return true;
}
while (!feof($rh )) {
if (fwrite($wh, fread( $rh, 1024)) === FALSE) {
// 'Download error: Cannot write to file ('.$file_target.')';
return true ;
}
}
fclose($rh);
fclose ($wh);
// No error
return false;
}

qw12er 09-26-2007 06:08 AM

note : I'd like not to use the FTP functions since I don't want to maintain an anonymous FTP account only for this file ...

Is there anyway to temporarily set the remote file opening option on ?

AcidMax 09-26-2007 06:23 AM

You could try ini_set to try and set the option you need on in the script, but I think you are going to have to use the fsockopen functions to do the remote ftp, or if your php version has the ftp functions compiled into it, just use php's ftp ability.


All times are GMT -7. The time now is 06:46 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123