My implementation was in fact using sfValidatorFile to validate the file's mime type, etc. Trusting this to be as the documentation said it is, I looked for every other possible reason why my files wouldn't upload.sfValidatorFile
is quite interesting as it does a number of things:
- Validates that the uploaded file is an image in a web format (
mime_types
)- Renames the file to something unique
- Stores the file in the given
path
- Updates the
logo
column with the generated name
Problem:
Files wouldn't upload properly in Symfony 1.4 even with using the sfValidatorFile.
Solution:
Manually loop over and move files to the upload directory.
The code I used in my actions file was like this:
I hope this helps someone figure out their code issues.
if ($this->form->isValid())
{
foreach ($request->getFiles($this->form->getName()) as $uploadedFile)
{
$uploadDir = sfConfig::get('sf_upload_dir') . '/assets';
move_uploaded_file($uploadedFile["tmp_name"], $uploadDir . "/" . $uploadedFile["name"] );
}
$this->redirect('media/thumbnailSelector?'.http_build_query($this->form->getValues()));
}
Happy coding.