[英]WordPress async-upload.php returns 500 (Internal Server Error) after uploading a large JPG file
[英]PHP SMB File upload is successful but returns 500 Internal Server Error
當我嘗試通過 SMB 將文件從 PC 上的本地文件夾上傳到 ftp 服務器時,文件已上傳,但服務器返回 500 內部服務器錯誤並顯示以下消息:
警告:fopen(File.xls):無法打開 stream:沒有這樣的文件或目錄
這是我上傳的function:
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”。 我已經嘗試為 function 提供整個路徑。 但它仍然會導致相同的錯誤。 上傳確實有效。文件在服務器上,但代碼無法繼續,因為它仍然導致 500 內部服務器錯誤。
這是來自 smb NativeShare 的 put() function:
/**
* Upload a local file
*
* @param string $source local file
* @param string $target remove file
* @return bool
*
* @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\Exception\InvalidTypeException
*/
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;
}
好吧..所以我能夠修復錯誤。 問題是我已經在某個地方使用了這個上傳 function,我假設我可以用相同的參數再次使用它。我需要更改參數,現在它可以工作了:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.