0

Hi,

I want to upload a file from one machine to another server ie application is in server A and path of the uploaded file is in server B. How can I implement this without using curl, ftp and ssh. The code which I have used is shown below. But it is not working

<form action="" method="post" enctype="multipart/form-data">
   <input type="file" name="vchr_req_upload" id="vchr_req_upload" />
    <input type="hidden" name="key" value="asdf1234sadfasfd34565xx" />
    <input type="submit" name="submit"> 
</form>

    <?php 

    if(isset($_REQUEST['submit']))
{
    echo $filename=basename($_FILES['vchr_req_upload']['name']);
        $path_info = pathinfo($filename);

             $target_path = "http://192.168.1.29/uploads/";
            $filename=basename($_FILES['vchr_req_upload']['name']);

            if ($_FILES["vchr_req_upload"]["error"] > 0)
            {
                echo "Apologies, an error has occurred.";
                echo "Error Code: " .$_FILES["vchr_req_upload"]["error"];
            }
            else
            {

                $res=move_uploaded_file($_FILES["vchr_req_upload"]["tmp_name"],$target_path);


            }
            }

        ?>
2
Contributors
1
Reply
18
Views
4 Years
Discussion Span
Last Post by pritaeas
0

move_uploaded_file does not work across servers. Depending on your servers' configuration, you may be able to use file_put_contents.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.