Is there a way to limit what types of files can be uploaded? #750

Open
opened 2017-04-20 14:35:52 +00:00 by snstarosciak · 6 comments
snstarosciak commented 2017-04-20 14:35:52 +00:00 (Migrated from github.com)

Are there some options you can pass to limit to just pdfs and image/jpg?

Are there some options you can pass to limit to just pdfs and image/jpg?
alexsalmon commented 2017-04-20 15:30:45 +00:00 (Migrated from github.com)

You could add an accept attribute to your inputs.

e.g.
accept=".pdf, image/jpg"

https://html.spec.whatwg.org/multipage/forms.html#attr-input-accept

You could add an `accept` attribute to your inputs. e.g. `accept=".pdf, image/jpg"` https://html.spec.whatwg.org/multipage/forms.html#attr-input-accept
RyanDrx commented 2017-08-23 02:02:53 +00:00 (Migrated from github.com)

You can add the files types when the uploader is constructed.
public uploader: FileUploader = new FileUploader( { url: URL, allowedMimeType: ['application/pdf', 'image/jpeg'] });

You can add the files types when the uploader is constructed. ` public uploader: FileUploader = new FileUploader( { url: URL, allowedMimeType: ['application/pdf', 'image/jpeg'] }); `
mcblum commented 2017-11-21 20:50:09 +00:00 (Migrated from github.com)

@RyanDrx maybe a dumb question but is there a way to say "only images" or "not images"?

@RyanDrx maybe a dumb question but is there a way to say "only images" or "not images"?
gauravpatni123 commented 2018-02-12 10:09:16 +00:00 (Migrated from github.com)

I tried to use by allowing mime type like below
public uploader: FileUploader = new FileUploader( { url: URL, allowedMimeType: ['application/pdf', 'image/jpeg'] });

but it is not working, did anyone tried this ?

I tried to use by allowing mime type like below public uploader: FileUploader = new FileUploader( { url: URL, allowedMimeType: ['application/pdf', 'image/jpeg'] }); but it is not working, did anyone tried this ?
hasanpathy commented 2018-02-21 05:10:40 +00:00 (Migrated from github.com)

the below callback 'onWhenAddingFileFailed ' will be called if your file format not matching.
this.uploader = new FileUploader({
allowedMimeType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template']
});

    this.uploader.onWhenAddingFileFailed = (item) => {
        console.log(item);
    }
the below callback 'onWhenAddingFileFailed ' will be called if your file format not matching. this.uploader = new FileUploader({ allowedMimeType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'] }); this.uploader.onWhenAddingFileFailed = (item) => { console.log(item); }
rajaramtt commented 2018-09-27 16:11:25 +00:00 (Migrated from github.com)

Add the allowedMimeType or allowedFileType It will be work.

Working Stackblitz Code example: https://stackblitz.com/edit/ng2-file-upload-example

Add the allowedMimeType or allowedFileType It will be work. Working Stackblitz Code example: https://stackblitz.com/edit/ng2-file-upload-example
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#750