0
我有以下函数定义:无法在UploadedFile的Symfony的获得文件内容
public function save(UploadedFile $file, string $fileSystemName)
{
$fs = $this->fileSystemMap->get($fileSystemName);
$contents = file_get_contents($file->getRealPath());
$filename = sprintf('%s/%s/%s/%s.%s', date('Y'), date('m'), date('d'), uniqid(), $file->getClientOriginalExtension());
$fs->write($fileName, $contents);
}
当代码运行:
的file_get_contents($文件 - > getRealPath());
它抛出一个错误说:
警告:的file_get_contents(/ tmp目录/ phpM9Ckmq):未能打开流:没有这样的文件或目录
请注意,我也试着使用$ file-> getPathName(),但结果是一样的。
这是怎么发生的?
谢谢!
提供您正在使用的sf版本 – habibun
为什么不使用移动方法? '$ file-> move($ directory,$ name)' – Orange18947