Let's say there is a file on a remote server that can be downloaded without any restrictions, ie. you can put the direct link to the file in your browser and it downloads the file, for example http://www.remotesite.com/video.avi will prompt your browser to download that file. Using php, what is the best way to grab that file and upload it to my local server without the file being downloaded to my PC at all, which is what happens with phpBB if you put a url in the file upload form? An example of the code needed would also be appreciated. Thanks
scp command is being used to copy files from a remote server to a local machine and vice versa. It uses ssh to do secure file transfer.
You can download any type of file (image, ZIP, video, audio, etc) from the remote server using PHP. Use the readfile() function with application/x-file-to-save Content-type header, to download a ZIP file from remote URL using PHP. header("Content-type: application/x-file-to-save");
Once you have remotely access the computer over RDP, you can use copy and paste to transfer files from remote machine to your local machine effortlessly.
Just use copy
$source = "http://www.remotesite.com/video.avi";
$dest = "video.avi";
copy($source, $dest);
$remote_file_contents = file_get_contents('http://remote_url/file/with.extension');
//Get the contents
$local_file_path = 'your/local/path/to/the/file/with.extension';
file_put_contents($local_file_path, $remote_file_contents);
//save the contents of the remote file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With