目前,我想将文件从任何扩展名发送到我的数据库。但是,实际上,当我通过表单打印文件的值返回时:我得到了这个:
Symfony \ Component \ HttpFoundation \ File \ UploadedFile对象([test:Symfony \ Component \ HttpFoundation \ File \ UploadedFile:private] =&gt; [originalName:Symfony \ Component \ HttpFoundation \ File \ UploadedFile:private] =&gt; IMPOTS 2016.pdf [mimeType:Symfony \ Component \ HttpFoundation \ File \ UploadedFile:private] =&gt; application / pdf [size:Symfony \ Component \ HttpFoundation \ File \ UploadedFile:private] =&gt; 1621929 [错误:Symfony \ Component \ HttpFoundation \ File \ UploadedFile:private] =&gt; 0 [pathName:SplFileInfo:private] =&gt; / var / www / clients / client1 / web1 / tmp / phpV9G6Sg [fileName:SplFileInfo:private] =&gt; phpV9G6Sg)< / p>
但我只想要文件的名称 - &gt; IMPOTS 2016.pdf 当我试图获得juste的名字时,symfony返回:
Error: Cannot access private property Symfony\Component\HttpFoundation\File\UploadedFile::$originalName
好的,这是我处理数据的功能:
public function AddFile($valeursForm)
{
$File = new Transfert;
$File->setDESTINATAIRE($valeursForm['DESTINATAIRE']->Id);
$File->setEMAIL($valeursForm['EMAIL']);
$File->setOF($valeursForm['OF']);
$File->setDEVIS($valeursForm['DEVIS']);
$File->setAFFAIRE($valeursForm['AFFAIRE']);
$File->setLOGICIEL($valeursForm['LOGICIEL']);
$File->setINFORMATION($valeursForm['INFORMATION']);
$File->setLIVRAISON($valeursForm['LOGICIEL']);
$file = $valeursForm['NOM_FILE'];
print_r($file);
$filename = $file->originalName;
$path = $this->ListeSocieteId($valeursForm['ID_SOCIETE']);
$path = $this->Core_Caracteres->RemplacementCaracteresSpeciaux($path->NOM);
$path = strtoupper($path);
$path = str_replace(" ", "_", $path);
$path = ('sermati/ftp/'.$path."/POUR_".$path);
$file->move(
$path,
$filename);
$File->setNOMFILE($filename);
print_r($filename);
$this->Core_ConnexionsBDD->Mise_a_jour_BDD('extranet',array($File));
//On créé le message d'alerte
$messageSucces = '<span class="glyphicon glyphicon-ok"></span> Le fichier a bien été ajoutée.';
$this->session->getFlashBag()->add('success',$messageSucces);
}
感谢您的帮助。