I have a file upload form in the frontend.
At the moment, when a new record is created, the file is uploaded to
%sf_data_dir%/files/
but due to some business logic I need the file to be uploaded to
%sf_data_dir%/files/%record_id%/
Therefore the uploaded file should be saved AFTER the record is created.
How can I achieve that?
If you use file upload, your form certainly make use of the sfValidatorFile (if not, that’s wrong):
This validator return a sfValidatedFile instance that can be saved anywhere you want (it’s safer than move_uploaded_file, there is checks on the directory, filename…).
In your action (or in the form, as you want/need), you can now do this:
Don’t hesitate to open sfValidatedFile to see how it work.