Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 传输文件us NuSOAP_Php_Soap_Nusoap_Soap Client_Soapserver - Fatal编程技术网

Php 传输文件us NuSOAP

Php 传输文件us NuSOAP,php,soap,nusoap,soap-client,soapserver,Php,Soap,Nusoap,Soap Client,Soapserver,我在使用NuSOAP传输文件时遇到问题。我知道您可以读取文件并将其作为字符串传输,但它不起作用。以下是一个例子: 客户: require('libraries/nusoap/nusoap.php'); $url = "http://www.example.com"; $client = new nusoap_client($url); args = array('file_name' => 'myfile.zip'); $return = $client->call('getFil

我在使用NuSOAP传输文件时遇到问题。我知道您可以读取文件并将其作为字符串传输,但它不起作用。以下是一个例子:

客户:

require('libraries/nusoap/nusoap.php');
$url = "http://www.example.com";

$client = new nusoap_client($url);
args = array('file_name' => 'myfile.zip');
$return = $client->call('getFile', array($args));

if(empty($return){
    echo "WHY IN THE WORLD IS THIS EMPTY!!!!!";
}
服务器:

require('libraries/nusoap/nusoap.php');
$server = new nusoap_server;

$server->configureWSDL('server', 'urn:server');

$server->wsdl->schemaTargetNamespace = 'urn:server';

$server->register('getFile',
   array('value' => 'xsd:string'),
   array('return' => 'xsd:string'),
   'urn:server',
   'urn:server#getFile');

function getFile($value){

$returnData= "";
$filePath=$value['file_path'];
$mode="r";

  if (floatval(phpversion()) >= 4.3) {
         $returnData= file_get_contents($filePath);
     } else {
         if (!file_exists($filePath)){ 
          return -3;
         }

         $handler = fopen($filePath, $mode);
         if (!$handler){ 
          return -2;
         }

         $returnData= "";
         while(!feof($handler)){
             $returnData.= fread($handler, filesize($filePath));
         }//end  while

         fclose($handler);
     }//end else

return $returnData;
}

这里是真正奇怪的部分。如果我返回文件名或文件大小或类似的内容,它将工作。它不会返回文件本身。请帮助。

在服务器端的getFile函数中,您应该
返回base64\u encode($returnData)

我编辑了这个问题,将一个缺少的$from-before值和一个;从行尾开始:$filePath=value['file\u path']