我尝试了许多不同的建议,包括uploadify论坛上的建议:http ://www.uploadify.com/forum/#/discussion/8232/upload-five-html-5-file-type-filter-capability/ p1
但是这些似乎并没有限制用户更改文件类型。有任何想法吗?这是我下面的代码:
<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
if ($('#fileupload').length > 0) {
$('#fileupload').uploadifive({
'auto' : true,
'checkScript' : '../home/assets/uploadifive/check-exists.php',
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
//'queueID' : 'queue',
'uploadScript' : '../home/assets/uploadifive/uploadifive.php',
'multi' : false,
'removeCompleted' : false,
'fileSizeLimit' : '3MB',
'uploadLimit' : 1,
'buttonText':'Select File',
onSelect: function() {
$('#btn_submit').attr({disabled: true, value:'Uploading...' }).css( "background-color", "#707070" );
},
onUploadComplete: function(file,data,reponse) {
$('#uploadedfile').val(data);
$("#btn_submit").attr({disabled: false, value:'Register' }).css( "background-color", "#D4D0C8" );
alert('The file ' + file.name + ' was successfully uploaded ');
},
// 'fileType' : 'application/pdf|application/doc|application/docx' //not
//working.
// 'fileType' : ["gif","jpeg","png"] //not working.
// 'fileType' : 'image/png|image/jpg' //not working.
// 'fileType' : 'image/*' // works but does not restrict user from changing
// it something else.
// 'fileType': ["image\/jpeg","image\/png"] // works but does not restrict user
// from changing it something else.
});
}
});
</script>