Reputation: 4666
I do the image hosting and I have a problem..
I have 3 servers.
First - Site/script
Any two servers for images.
How I Can upload image from "one" server (script) to second and third servers?
<?php
if (isset($_POST['upload']))
{
$blacklist = array('.php', '.phtml', '.php3', '.php4', '.php5');
foreach ($blacklist as $item)
{
if(preg_match('#' . $item . '\$#i', $_FILES['file']['name']))
{
echo "We do not allow uploading PHP files\n";
exit;
}
}
$uploadDir = PROJECT_ROOT . 'upload/'; // 1ST SERVER (THIS SERVER)
$uploadFile = $uploadDir . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile))
{
echo "File is valid, and was successfully uploaded.\n";
}
else
{
echo "File uploading failed.\n";
}
}
?>
<form name="upload" method="post" enctype="multipart/form-data">
Select the file to upload: <input type="file" name="file"/>
<input type="submit" name="upload" value="upload"/>
</form>
Upvotes: 3
Views: 4619
Reputation: 512
You can use Zend_Http Client to upload the files to other servers per HTTP the same way an HTML Upload Form would do it. You can find all the information you need here in the Section "File Uploads": http://www.zendframework.com/manual/en/zend.http.client.advanced.html
For getting started you should read also this:
http://www.zendframework.com/manual/en/zend.http.client.html
Basically the code you need is:
require_once('Zend/Http/Client.php');
$client = new Zend_Http_Client("http://serverurl/path");
$client->setFileUpload(...);
$client->request();
Upvotes: 0
Reputation: 31647
If you already have HTTP servers runing on the other servers, use cURL. Usage:
The HTTP request can be configured using curl_setopt. Especially of interest are the options CURLOPT_URL, CURLOPT_POST and CURLOPT_POSTFIELDS.
Upvotes: 0
Reputation: 19251
You could use ftp. PHP has fairly easy way to do this. Check this link.
http://www.php.net/manual/en/book.ftp.php
Upvotes: 4