How to upload a file to another website from my application using php or curl request.
What protocols do you have available to upload the file? That is probably where the answer will lie. The remote server that you intend on connecting to (remote website), what services do they have available for uploading? FTP, Upload Web Service, Upload Page, SSH?
Without knowing that, you can't do much, unless you control the remote website, but you need to provide extra detail.
If for example, it's FTP:
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file
";
} else`enter code here` {
echo "There was a problem while uploading $file
";
}
// close the connection
ftp_close($conn_id);
?>