Preserve an existing file upload
This is an open discussion with 24 replies, filed under General.
Search
Surely that is the culprit. AFAIK, @ellie's concept—keeping a file by passing the file's path in the POST request—is not a feature of Symphony (nor does it sugest itself, to be honest). It works with older PHP versions, only because PHP's error fallback prevents Symphony from overwriting/deleting the file in this case.
So I don't think that this can be fixed, unless we imlement this special "POST behaviour" for files in Symphony. At the moment Symphony will keep a field's value if the field is not sent at all, see my suggested solution.
That said, of course Symphony shouldn't throw such an error.
I, see. I always thought that passing the path was more reliable than not passing it, in order to keep an existing file.
I guess the second setup doesn't display errors because, with the input field type being hidden, PHP doesn't know it's a file...
Thanks, Michael. I like your approach, but for the two projects I need this, I think it would be better to use a separate form for files. There are a number of fields and by reloading the form I'll have to think about preserving data users have already entered.
Create an account or sign in to comment.
Hi, Michael.
With the original setup,
I've got this in the request body,
with the option to keep the existing file, which throws the
Illegal string offset 'name'
error,and with the option to remove the file, which does that, and I can see the 0 value of the field in the post-values with ?debug:
The second setup,
keeps the existing file regardless of the option.
The first option, to keep the file:
and the option to remove the file:
As I mentioned, the first setup is identical to what I use for a project on a live server, where I have PHP 5.3.10 and no errors for that. I tested it, the request was the same:
Thank you for your help.