Hello,
I have a page where i can upload images. Now i need to copy the uploaded images to a third party server. I have the details of that page. so can anyone help me.
Thank You.
Hello,
I have a page where i can upload images. Now i need to copy the uploaded images to a third party server. I have the details of that page. so can anyone help me.
Thank You.
using FTP u can upload the files to another server.
$file1 = "example.jpg";
$file2 = fopen("ftp://username:password@sitename.com/" . $file1, "w");
$txt= file_get_contents($file1);
fwrite($file2, $file1, strlen($txt));
fclose($file2);
Using CURL also u can upload the files
visit the following links
http://dtbaker.com.au/random-bits/up...rl-in-php.html
here is my code to copy files to images folder in root directory. how can i make that copy to another server..
if ($_FILES["file1"]["error"] > 0 && $_FILES["file2"]["error"] > 0 )
{
echo "Return Code: " . $_FILES["file1"]["error"] . $_FILES["file2"]["error"] . "<br />";
}
else
{
/* echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb<br />";
echo "Size: " . ($_FILES["file2"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
*/
if (file_exists("images/$dirname/" . $_FILES["file1"]["name"]))
{
echo $_FILES["file1"]["name"] . " already exists. ";
}
else if (file_exists("images/$dirname/" . $_FILES["file2"]["name"]))
{
echo $_FILES["file2"]["name"] . " already exists. ";
}
else
{
$dirname=$_POST['first_name'] . $_POST['last_name'];
$path="images/$dirname";
if(!is_dir($path))
{
@mkdir($path,0777,true);
}
move_uploaded_file($_FILES["file1"]["tmp_name"],"images/$dirname/" . $_FILES["file1"]["name"]);
move_uploaded_file($_FILES["file2"]["tmp_name"],"images/$dirname/" . $_FILES["file2"]["name"]);
//echo "Stored in: " . "images/$dirname" . $_FILES["file"]["name"];
$src1="images/$dirname/" . $_FILES["file1"]["name"];
$src2="images/$dirname/" . $_FILES["file2"]["name"];
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.