如何创建验证大小的函数。请参阅以下代码:
var filename = $(this).get(0).files; //e.g. 2MB
var maxFileSize = 10; //in megabytes (MB)
IsFileSizeValid(file, maxFileSize); //returns true or false
//Check file size is valid
function IsFileSizeValid(filename, maxFileSize) {
/*TODO*/
}
答案 0 :(得分:0)
$(this).get(0).files[0].size/1048576
- 以字节为单位获取第一个文件大小
1048576
- 在MiB中,2^20
为1024^2
或ViewGroup headerView = (ViewGroup) inflater.inflate(R.layout.item_header, list, true);
list.addHeaderView(headerView);
list.setAdapter(musicBaseAdapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Intent intent = new Intent(getActivity(), RedActivity.class);
intent.putExtra("rank", position);
startActivity(intent);
}
});
headerView.setOnClickListener(new ViewGroup.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.text1:
log.d("text1");
break;
case R.id.text2:
log.d("text2");
break;
case R.id.text3:
break;
case R.id.text4:
break;
}
}
});