Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to upload a file into a server using code in another server using php?

    Hi,
    I am using a unlimited server for uploading some files but after using so many code , i am not able to achieve my goal.
    So now i want i use my current server to php code and upload my files into another server, where limit will not be any issue.

    Example.
    Let's say i have two server ( [www.rajesh.com and www.rathor.com),

    now i am using below code into [www.rajesh.com]

    Code:
    if (file_exists("http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]))
    	 {
          echo $_FILES["uploadedfile"]["name"] . " already exists. ";
        }
    	 else
    	  {
          move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],
          "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]);
          echo "Stored in: " . "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"];
        }
    So i just want to know, is it possible to do?
    if yes then how i can achieve this?

    Thanks
    Last edited by rajeshkr; 04-28-2014 at 09:14 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    You cannot use move_uploaded_file() on a remote server. If you could that would be a massive security risk as anyone could move anyone elses files on other sites. EG I could move lots of files on yahoo.com.

    You need a script on your other server to handle a $_POST submission with files. Then on your main server you need to write code that uses cURL to send each file as a POST form submission. You could alternatively use FTP instead in your script.
    I can't really think of anything to write here now...

  • #3
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    You cannot use move_uploaded_file() on a remote server. If you could that would be a massive security risk as anyone could move anyone elses files on other sites. EG I could move lots of files on yahoo.com.

    You need a script on your other server to handle a $_POST submission with files. Then on your main server you need to write code that uses cURL to send each file as a POST form submission. You could alternatively use FTP instead in your script.
    hi,
    I by using ftp also i am not able to upload files may be the reason that first it will upload in current server then it will move.
    and the current server not allowing me to upload more than 20MB.
    Thanks


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •