小编Rai*_*ain的帖子

无法使用PhantomJS上传

我的服务器上有一个php文件来上传文件.我试图直接使用该文件上传,但它很成功.

然后我写了一个简单的phantomjs脚本,使用phantomjs 2.1.1版在ubuntu上运行它,但它不成功.没有显示错误但文件未上传.

以下是php文件:

<?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;
}
?>
Run Code Online (Sandbox Code Playgroud)

和简单的phantomjs脚本上传文件

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 …
Run Code Online (Sandbox Code Playgroud)

javascript upload phantomjs

2
推荐指数
1
解决办法
1940
查看次数

标签 统计

javascript ×1

phantomjs ×1

upload ×1