I have a php file on my server to upload file. I tried to upload using that file directly and it was success.

Then I wrote a simple phantomjs script, run it on ubuntu with phantomjs version 2.1.1 but it is not success. There was no error displayed but file was not upload.

Below are php file:

```
<?php
if(isset($_FILES["files"]))
{
    $files = $_FILES["files"];
    if($files["name"] != '')
    {

            $fullpath = "./".$files["name"];
            if(move_uploaded_file($files['tmp_name'],$fullpath))
            {                      
                    echo "<h1><a href='$fullpath'>OK-Click here!</a></h1>";        
            }
    }
    echo '<html><head><title>Upload files...</title></head><body><form method=POST enctype="multipart/form-data" action=""><input type="file" name="files"><input type="submit" value="Upload"></form></body></html>';
return;
}
?>

```

And simple phantomjs script to upload file

```
var webPage = require('webpage');
var page = webPage.create();
var testindex = 0, loadInProgress = false;

page.onLoadStarted = function() {
  loadInProgress = true;
  console.log("load started");
};

page.onLoadFinished = function() {
  loadInProgress = false;
  console.log("load finished");
};

function load()
{
    page.open("http://myserver.com/upload.php?cmd=upload")  
}

function upload()
{
    page.uploadFile('input[name=files]', '/home/user/Desktop/log_no_debug.png');    
    page.render("result.png")
}

var steps = [
    load,
    upload
]

interval = setInterval(function() {
  if (!loadInProgress && typeof steps[testindex] == "function") {
    //console.log("step " + (testindex + 1));
    steps[testindex]();
    testindex++;
  }
  if (typeof steps[testindex] != "function") {
    //console.log("test complete!");
    phantom.exit();
  }
}, 50);    

```

Below are result.png rendered from the upload.js script

![result render](https://i.imgur.com/se19jXr.png)