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