PHP SMB文件上传导致500内部服务器错误
P粉113938880
P粉113938880 2023-08-30 13:53:12
0
1
595
<p>当我尝试通过SMB将本地文件夹上的文件上传到FTP服务器时,文件会被上传,但服务器返回一个500内部服务器错误,并显示以下消息:</p> <blockquote> <p>警告:fopen(File.xls):无法打开流:没有这个文件或目录</p> </blockquote> <p>这是我的上传函数:</p> <pre class="brush:php;toolbar:false;">public function upload($fileToUpload, $targetPath = "") { if (!empty($targetPath)) { if (substr($targetPath, -1, 1) != '/') { $targetPath .= "/"; } } $fileName = basename($fileToUpload); $this->srvShare->put($fileToUpload, $targetPath . $fileName); }</pre> <p>在这种情况下,<strong>$fileToUpload</strong> 是类似 'File.xls' 的内容。 我已经尝试给函数传递整个路径,但仍然导致相同的错误。 上传是成功的...文件已经在服务器上,但代码无法继续执行,因为仍然导致500内部服务器错误。</p> <p>这是smb NativeShare中的put()函数:</p> <pre class="brush:php;toolbar:false;">/*** 上传本地文件 * * @param string $source 本地文件 * @param string $target 目标文件 * @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; }</pre></p>
P粉113938880
P粉113938880

全部回复(1)
P粉882357979

好的..所以我成功修复了错误。 问题是我已经在其他地方使用了这个上传功能,并且我假设我可以再次使用它,并且参数相同..我需要更改一个参数,现在它可以工作:)

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!