PHP SMB文件上载成功,但返回500内部服务器错误



当我试图通过SMB将文件从pc上的本地文件夹上传到ftp服务器时,文件会被上传,但服务器会返回500内部服务器错误,并显示以下消息:

警告:fopen(File.xls(:无法打开流:没有这样的文件或目录

这是我的上传功能:

public function upload($fileToUpload, $targetPath = "") {
if (!empty($targetPath)) {
if (substr($targetPath, -1, 1) != '/') {
$targetPath .= "/";
}
}
$fileName = basename($fileToUpload);
$this->srvShare->put($fileToUpload, $targetPath . $fileName);
}

$fileToUpload在这种情况下类似于"File.xls"。我已经试着给出函数的整个路径。但它仍然会导致同样的错误。上传确实有效。。文件在服务器上,但代码无法继续,因为它仍然导致500内部服务器错误。

这是smbNativeShare:中的put((函数

/**
* Upload a local file
*
* @param string $source local file
* @param string $target remove file
* @return bool
*
* @throws IcewindSMBExceptionNotFoundException
* @throws IcewindSMBExceptionInvalidTypeException
*/
public function put($source, $target) {
$sourceHandle = fopen($source, 'rb');
$targetUrl = $this->buildUrl($target);
$targetHandle = $this->getState()->create($targetUrl);
while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
$this->getState()->write($targetHandle, $data, $targetUrl);
}
$this->getState()->close($targetHandle, $targetUrl);
return true;
}

好的。。所以我能够修复错误。问题是,我已经在某个地方使用了这个上传功能,我认为我可以使用相同的参数再次使用它。。我需要更改参数,现在它可以工作了:(

最新更新