Created
July 23, 2013 18:38
-
-
Save ZZromanZZ/6064967 to your computer and use it in GitHub Desktop.
curl get ftpAuth file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function saveFtpFile( $targetFile = null, $sourceFile = null, $ftpuser = null, $ftppassword = null ){ | |
// function settings | |
$timeout = 50; | |
$fileOpen = 'w+'; | |
$curl = curl_init(); | |
$file = fopen (dirname(__FILE__) . '/'.$targetFile, $fileOpen); | |
curl_setopt($curl, CURLOPT_URL, $sourceFile); | |
curl_setopt($curl, CURLOPT_USERPWD, $ftpuser.':'.$ftppassword); | |
// curl settings | |
curl_setopt($curl, CURLOPT_FAILONERROR, 1); | |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); | |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($curl, CURLOPT_FILE, $file); | |
$result = curl_exec($curl); | |
$info = curl_getinfo($curl); | |
curl_close($curl); | |
fclose($file); | |
return $result; | |
} | |
//saveFtpFile("", "", "", ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment