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);


            }
            }

        ?>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.