flowjs/flow-php-server

MIME types

Opened this issue · 2 comments

I can't find any way to get the mime type of the file from either the Flow\Request or the Flow\File object? If this functionality does not exist, I'd be glad to make a pull request for it, but I don't want to go reinventing the wheel and it seems like a pretty important thing to omit.

I think this more of applies to ng-flow than the PHP backend. You can detect the mime type after assembling the file from chunks into a complete file, either at Flow\File->save or more conveniently in Flow\Basic after if ($file->validateFile() and $file->save($destination)). But if you want to filter out files for the uploader itself, it's kinda too late at this point.

The only convenient way to filter out unwanted filetypes (cruedly, but still that's something) is to init flow with appropriate options, i.e. before adding any files to the uploader, for example:

<div flow-init flow-file-added="!!{png:1,jpg:1,jpeg:1}[$file.getExtension()]" flow-files-submitted="$flow.upload()">