This forum is a community forum meant for users of the plugin to collaborate and help solve issues with implementation, etc. Unfortunately, as the creator of the plugin, I do not have much time to attend to every request here as this is only a side project and I must work a full-time job to provide for my family. This is how I keep the Flash version free and the HTML5 version low cost.
UploadiFive 1.1.1 has been released which includes a small fix for added support on touch devices including iOS 6 devices.
FileType. Upload only certain extensions
  • I really can't work out handling file extensions. I would like Uploadifive to check for admitted file extension as the user selects the file/files to upload and popup an Alert for prohibited extensions. I tried some code I found in the Uploadify forum section but I don't know well javascript so I'm pretty sure I'm missing something. I simply tried to modify the demo script as follows. This simply does nothing.

    I did not used a JSON array because I don't know how to do it :-/


    'onselect' : function(event,queueID,fileObj){
    var fileName = fileObj.name;
    var ext = FileName.substring(fileName.lastIndexOf(".")+1,fileName.length); // Extract EXT
    switch (ext) {
    case 'xls':
    case 'txt':
    alert('filetype ok');
    break;
    default:
    alert('filetype not ok');
    $jQuery('#queue').uploadifyCancel(queueID);
    break;
    }
    }


    Thank you.

  • Use the onAddQueueItem event function instead.

    ** Note the change to the cancel.

    'onAddQueueItem' : function(file){
    var fileName = file.name;
    var ext = FileName.substring(fileName.lastIndexOf(".")+1,fileName.length); // Extract EXT
    switch (ext) {
    case 'xls':
    case 'txt':
    alert('filetype ok');
    break;
    default:
    alert('filetype not ok');
    $('#file_upload').uploadifive('cancel', file);
    break;
    }
    }

  • Sorry, but still it does not work. I also tried the following code simply adding 'onAddQueueItem' to your demo code but it does nothing. No alert is shown.


    <form>
    <div id="queue"></div>
    <input id="file_upload" name="file_upload" type="file" multiple="true">
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
    </form>

    <script type="text/javascript">
    $(function() {
    $('#file_upload').uploadifive({
    'auto' : false,
    'dnd' : true,
    'queueID' : 'queue',
    'uploadScript' : 'uploadifive.php',
    'onAddItemQueue' : function(file) {
    alert('The file ' + file.name + ' was added to the queue!');
    }
    });
    });
    </script>


    Regards.
  • The reason the demo code isn't working is because I had a typo in it. onAddItemQueue should be onAddQueueItem. Also, in the first code I posted, I apologize for not checking my code better. Try this:

    'onAddQueueItem' : function(file){
    var fileName = file.name;
    var ext = fileName.substring(fileName.lastIndexOf('.') + 1); // Extract EXT
    switch (ext) {
    case 'xls':
    case 'txt':
    alert('filetype ok');
    break;
    default:
    alert('filetype not ok');
    $('#file_upload').uploadifive('cancel', file);
    break;
    }
    }
    }

    Of course, don't forget to do an extension check in the backend file as well.
  • It works! Perfect!
  • Yes it worked for me as well fine. At least it works. Would be great if you can make it work in IE9. Thanks