0

在 scriptdata 下,在 fileext 中如何指定允许的文件类型?

例如:

$('#file_mainfile').uploadify({
        'uploader'  : '<?php echo WPDEPOSIT_URL; ?>/resources/js/uploadify/uploadify.swf',
        'script'    : '<?php echo $uploadPath; ?>',
        'cancelImg' : '<?php echo WPDEPOSIT_URL; ?>/resources/images/cancel.png',
        'folder'    : '<?php echo $fileFolder; ?>',
        'auto'      : true,
        'fileExt'   : '*.zip',
        'buttonText': '<?php _e('Upload .zip', WPD_SHOPPER_NAME); ?>',
        'method'    : 'post',
        <?php if(WPDS_AMAZONS3_ACTIVE == 'on'): ?>
        'fileDataName'  : 'file',
        'auto'          : 'true',
            'scriptData' : {
                "AWSAccessKeyId"                                : "<?php echo $amazonClass->AWS_ACCESS_KEY; ?>",
                "key"                       : "${filename}",
                "acl"                       : "public-read",
                "policy"                    : "<?php echo $policy; ?>",
                "signature"                 : "<?php echo $signature; ?>",
                "success_action_status"                         : "201",
                "key"                       : encodeURIComponent(encodeURIComponent("<?php echo $folder; ?>${filename}")),
/* here ---->  */    "fileext"                  : encodeURIComponent(encodeURIComponent("")),
                    "Filename"                  : encodeURIComponent(encodeURIComponent(""))
                },

我实际上已经指定了允许的扩展名;'fileExt' : '*.zip',. 但我仍然可以上传其他文件类型。

4

1 回答 1

0

从文档中,我从来没有遇到过使用这种语法的问题。当语法为 fileTypeExts 时,您正在指定 fileext。

可以上传的允许扩展名列表。手动输入的文件名可以绕过此级别的安全性,因此您应该始终检查服务器端脚本中的文件类型。多个扩展名应该用分号分隔(即'*.jpg; *.png; *.gif')。

http://www.uploadify.com/documentation/uploadify/filetypeexts/

$(function() {
    $("#file_upload").uploadify({
        'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.gif; *.jpg; *.png',
        'swf'          : '/uploadify/uploadify.swf',
        'uploader'     : '/uploadify/uploadify.php'
    });
});
于 2013-01-17T15:03:55.857 回答