I have an Apache server running on a client's computer, with PHP installed. I have scheduled a task to automatically create a database backup, and it's working fine. But it makes no sense keeping the backups on the same HD the system's running, so I have to send it somewhere else.
At first, I tried doing a PHP FTP Upload, but the client's firewall's blocking all FTP connections, and I cannot unblock it (his company won't allow me).
Then, I tried sending the backup using SMTP, to an e-mail account. Also didn't work. All SMTP connections are also blocked (I know...).
I'm trying now to access a webpage (on my server), via a HTTP POST REQUEST, with the file attached on the page-header. It should be possible, seeing that's pretty much what the browser does, with a file-input object, right? I just sends the multipart/data using the page header.
Will I have to create the page header manually? Or are there any scripts that already do that?
HTTP Request action allows you to upload files on a specified service.
To transfer files between 2 Windows servers, the traditional way is to use FTP desktop app as a middle-man. You need to download Filezilla or other FTP desktop tool, configure and use it to upload or download files between two remote servers.
An HTTP file transfer is the process of transferring a file between multiple nodes/devices using the HTTP protocol, or more generally, the Internet. It is one of the most commonly used methods for sending, receiving or exchanging data and files over the Internet or a TCP/IP-based network.
You can use curl to send it via http. Assuming your file is '/tmp/backup.tar.gz', it'd be:
$ch = curl_init('http://clientserver.com/upload.php');
$ch = curl_setopt($ch, CURLOPT_POST, true);
$ch = curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@/tmp/backup.tar.gz'));
$ch = curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
$result = curl_exec($ch);
if ($result === FALSE) {
die(curl_error($ch));
}
That's the basics. you'd probably need to make it a bit more robust. Assuming the upload script on the receiving server is done in php, you'd access the file as $_FILES['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