我想用我的php腳本上傳一個csv文件,但似乎只有第一行被髮送到服務器。我嘗試了幾個解決方案,因爲把q循環,但都不while(! feof($handle)){ $data=fgetcsv($handle, 1000, ","); ...}
,但它崩潰。PHP將csv文件上傳到服務器陣列
如果有人能幫助我。 謝謝。
這裏我的PHP腳本:
<?php
$URL = 'https://mutalyzer.nl/services/?wsdl';
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mutalyzer SOAP client</title>
</head>
<body>
<h1>Mutalyzer SOAP client</h1>
<?php
if (isset($_GET['data']) && $_GET['data']) {
echo $_GET['data'];
$variant = $_GET['data'];
echo $variant;
//$filename = basename($_FILES['data']['name']);
$_FILES['data']['name']=$_GET['data'];
$filename = basename($_FILES['data']['name']);
$handle = fopen($filename, "r");
$data = fgetcsv($handle, 1000, ",");
/*while(! feof($handle)){
$data = fgetcsv($handle, 1000, ",");
//print_r($data);
}*/
//$encripData = base64_encode($variant);
$NameChecker=$_GET['process'];
echo '<h2>Result for '.htmlentities($variant).'</h2>';
$options = array('features' => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($URL, $options);
//while(! feof($handle)){
//$data=fgetcsv($handle, 1000, ",");
$result = $client->submitBatchJob(array('data' => $data[0], 'process' =>$NameChecker))
->submitBatchJobResult;
//print_r(array('data' => $data, 'process' =>$NameChecker));
//}
print_r($result);
}
?>
<h2>Submit job data file to MUTALYZER</h2>
<form action="" method="GET" enctype="multipart/form-data">
<p>
Input file:
</p>
<input name="data" type="file" id="data" />
<br/>
Process :
<input type="text" size="10" name="process" id="process" value="NameChecker"/>
<br/>
<input type="submit" name="upload" value="Submit" />
</form>
</body>
</html>
你能提供詳細信息你得到的錯誤和你打的服務的WSDL?只是猜測 - 在'$ result = $ client-> submitBatchJob(array('data'=> $ data [0],'process'=> $ NameChecker)中的'$ data [0]'值中不存在問題。 - > submitBatchJobResult;'(也許它必須是'$ data')? –
@MilanTomeš,嗨,我做了$ data [0]到$ data的更改我有這些錯誤:'code'使用未定義的常量SOAP_SINGLE_ELEMENT_ARRAYS - 假定'SOAP_SINGLE_ELEMENT_ARRAYS''code'還有:'code'Fatal error:Uncaught錯誤:在C:\ xampp \ htdocs \ ngs \ submit.php中找不到類'SoapClient':34堆棧跟蹤:#0 {main}拋出的代碼' – user979974