My problem is that when i try to upload an mp3 file using VichUploadBundler in combination with sonata-admin, i get the following error when i upload the file.
"The file "" was not found"
I aleady have another form inside my project where i upload some images and i have no problem with them, so im quite shock, because i thought that audio files would be easier
Here is my Entity file
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="episode_audio", fileNameProperty="audioName")
*
* @var File
*/
private $audioFile;
/**
* @ORM\Column(type="string", length=255)
*
* @var string
*/
private $audioName;
/**
* @ORM\Column(type="datetime")
*
* @var \DateTime
*/
private $updatedAt;
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $audioFile
*/
public function setAudioFile(?File $audioFile = null): void
{
$this->audioFile = $audioFile;
if (null !== $audioFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getAudioFile(): ?File
{
return $this->audioFile;
}
public function setAudioName(?string $audioName): void
{
$this->audioName = $audioName;
}
public function getAudioName(): ?string
{
return $this->audioName;
}
My vich_uploader.yaml file
vich_uploader:
db_driver: orm
mappings:
..//
episode_audio:
uri_prefix: /audio
upload_destination: '%kernel.project_dir%/public/audio/'
delete_on_update: true
delete_on_remove: true
inject_on_load: true
And finally my admin class
protected function configureFormFields(FormMapper $formMapper) {
$formMapper
->add('audioName')
->add('audioFile', VichFileType::class, [
'label' => 'Audio'
]);
}
I just want to be able to see my audio files on my folder, just like the images, im pretty sure is something silly, if you guys need to see something else in my code, just ask so i can update the question