There are still 2 possible ways which can used to copy your files from another server.
-One is to remove your .htaccess file from example.com or allow access to all files(by modifying your .htaccess file).
-Access/Read those files via their respective URLs, and save those files using 'file_get_contents()' and 'file_put_contents()' methods. But this approach will made all files accessible to other people too.
$fileName = 'filename.extension';
$sourceFile = 'http://example.com/path-to-source-folder/' . $fileName;
$targetLocation = dirname( __FILE__ ) . 'relative-path-destination-folder/' + $fileName;
saveFileByUrl($sourceFile, $targetLocation);
function saveFileByUrl ( $source, $destination ) {
if (function_exists('curl_version')) {
$curl = curl_init($fileName);
$fp = fopen($destination, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
} else {
file_put_contents($destination, file_get_contents($source));
}
}
Or you can create a proxy/service on example.com to read a specific file after validating a pass key or username/password combination(whatever as per your requirement).
//In myproxy.php
extract($_REQUEST);
if (!empty($passkey) && paskey == 'my-secret-key') {
if (!empty($file) && file_exists($file)) {
if (ob_get_length()) {
ob_end_clean();
}
header("Pragma: public");
header( "Expires: 0");
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0");
header( 'Content-Type: ' . mime_content_type($file) );
header( "Content-Description: File Transfer");
header( 'Content-Disposition: attachment; filename="' . basename( $file ) . '"' );
header( "Content-Transfer-Encoding: binary" );
header( 'Accept-Ranges: bytes' );
header( "Content-Length: " . filesize( $file ) );
readfile( $file );
exit;
} else {
// File not found
}
} else {
// You are not authorised to access this file.
}
you can access that proxy/service by url 'http://example.com/myproxy.php?file=filename.extension&passkey=my-secret-key'.