【发布时间】:2020-04-19 06:03:05
【问题描述】:
请查看下面我用来将文件上传到 orthanc 的代码。我不确定这个错误是来自 orthanc 配置还是因为 CURL
$total = count($_FILES['file']['name']);
$tmp_name = array();
for ($i = 0; $i < $total; $i++) {
$tmpFilePath = $_FILES['file']['tmp_name'][$i];
array_push($tmp_name, $tmpFilePath);
}
$postfields = array();
foreach ($tmp_name as $index => $file) {
$file = '@' . realpath($file);
$postfields["file_$index"] = $file;
}
$url = 'http://localhost/instances';
$postfields = $postfields;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); //require php 5.6^
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
if (curl_errno($ch)) {
//print curl_error($ch);
}
curl_close($ch);
$json = json_decode($postResult, true);
print_r($json);
这是我得到的错误。
Array ( [Details] => Cannot parse an invalid DICOM file (size: 28 bytes) [HttpError] => Bad Request [HttpStatus] => 400 [Message] => Bad file format [Method] => POST [OrthancError] => Bad file format [OrthancStatus] => 15 [Uri] => /instances )
【问题讨论】:
-
似乎“DICOM 文件”已损坏或扩展名错误
-
不,我已经下载了新的 DICOM 文件。
标签: php curl file-upload dicom