错误为GAE的PHP脚本中的空CurlFile对象

时间:2016-03-06 05:08:53

标签: google-app-engine

我有一个小的PHP脚本,它不适用于GAE ..当执行php curlfile对象为空时。这可以很好地使用App引擎,但使用wampserver。

我打算做的是从多部分请求中获取文件。将该文件上传到我在$ url中指定的3000端口上运行的另一个服务。

$url = "http://service:3000/tasks.test.payload/uploads/".$_FILES['file']['name'];
        ConsoleLog($url);

        $fname = $_FILES['file']['name'];

        $file = new CURLFile(realpath($_FILES['file']['tmp_name']));
        var_dump($file);
        $post = array (
                  'file' => $file
                  );    

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");   
        curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data','Application: service-console-uploader'));
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);   
        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);  
        curl_setopt($ch, CURLOPT_TIMEOUT, 100);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        $result = curl_exec($ch);
        curl_close ($ch);
        $status = "false";

        if ($result === FALSE) {
            ConsoleLog("Error sending" . $fname);   
            $status = "false";          
        }else{
            ConsoleLog($result);
            $status = "true";
        }

我已将这3行添加到php.ini文件中..而且也启用了Appengine Billing。 extension="curl.so" extension=php_curl.dll google_app_engine.enable_functions = "php_sapi_name, php_uname"

我得到的var_dump结果是......

object(CURLFile)#27 (3) { ["name"]=> string(0) "" ["mime"]=> string(0) "" ["postname"]=> string(0) "" }

我该如何解决这个问题?

0 个答案:

没有答案