Bonjour;
Dernier soucis pour finir mon application sf2, a partir de la doc officielle j'ai pu réaliser ses méthodes qui permet l'upload d'un fichier !!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public function getWebPath()
{
return null === $this->file ? null : $this->getUploadDir().'/'.$this->file;
}
protected function getUploadRootDir()
{
return __DIR__.'/../../../../web/'.$this->getUploadDir();
}
protected function getUploadDir()
{
// chemin de sauvegarde
return 'Test';
}
public function uploadFile()
{
$this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName());
$this->file = $this->file->getClientOriginalName();
//$this->file = null;
}
public function removeFile()
{
if ($file = $this->getWebPath()) {
unlink($file);
}
} |
Le seul chemin de sauvegarde des fichiers c'est (enfait c'est juste un test) or mon application prévoit 4 chemins déffirents qui sont :
1 2 3 4
| Symfony/web/App/Application1/Media/Image
Symfony/web/App/Application2/Media/Image
Symfony/web/App/Application3/Media/Image
Symfony/web/App/Application4/Media/Image |
ca revient a définir le chemin avec une variable (nom de l'appli) :
Symfony/web/App/$nomApplication/Media/Image
Quelqu'un peut m'aider a réaliser cela ?
Merci d'avance.
Partager