symfony - Symfony2 UploadedFile::guessExtension() for XML -
I'm having trouble with extensions for XML files uploaded I tried getExtension ()
(Empty string returns), estimationExtension ()
and guessClientExtension ()
(both returns NULL
).
Am I just a hardcode extension (I know that it should always be XML) or is there any way to get it? I think the uploaded file has a mm type text / xml
when I upload a .txt file, this extension is cured.
Maybe I'm getting the upload file wrong?
$ request = $ this- & gt; GetRequest (); $ Form = $ this- & gt; CreateForm (new file type type), empty, ['em' => $ this-> getDoctrine () - & gt; getManager ()]); $ Form & gt; ($ Request) deposit; If ($ form-> isValid ()) {$ file = null; // @ War $ file \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile foreach ($ request-> Files as $ file) {$ file = $ file ['file']; break; } Var_dump ($ file-> EstimateExchange ()); }
thanks
getting it from the uploaded $ Try File-> getFilename () Then you can extract the extension using:
in php docs:
Comments
Post a Comment