JeremyFagis / dropify

Override your input files with style — Demo here : http://jeremyfagis.github.io/dropify
MIT License
973 stars 399 forks source link

Allowed File Extensions Not Working #42

Open crawpappy opened 8 years ago

crawpappy commented 8 years ago

I'm attempting to limit file types that can be uploaded and this option does not appear to be working. Using the following markup and script everything else is working fine but it will still allow me to upload any file type. For example, I was just able to upload a .zip file.

    $('.dropify').dropify({
    messages: {
        'default': 'Drag and drop a file here or click to select manually',
        'replace': 'Drag and drop or click to replace',
        'remove':  'Remove',
        'error':   'Ooops, something went wrong'
    }
    <div class="col s8" style='padding-top: 10px'>
        <label>Upload proof of certification <span class='red-text text-lighten-2'><?php echo $fileerr ?></span></label>
        <input type="file" name="fileToUpload" id="fileToUpload" class="dropify" data-max-file-size="10M" data-allowed-file-extensions="pdf png psd">
    </div>
qlerebours commented 8 years ago

I had the same problem and I solved it: I get the source file from a template, and it was an old version of dropify.js that doesn't contains "allowedFileExtensions" variable. Get the latest version should solve this issue.

Regards

crawpappy commented 8 years ago

I'm linking it straight from github currently:

<script src="http://jeremyfagis.github.io/dropify/dist/js/dropify.js"></script>

qlerebours commented 8 years ago

As I said previously, this is because it is an old version of the file. The file on github.io is not up to date. The latest version include the file extensions validation but the content of your file doesn't contain the "allowedFileExtension" variable. I advise you to use the code from github that is up to date in dist and src directory.

nguyencnttk8c commented 6 years ago

Thank you so much @qlerebours. Solved it.

glennthehuman commented 6 years ago

The file extensions are case sensitive :(