我有一个带有文件输入的表单来处理图像或视频的文件上传。我想将接受的文件类型限制为 .jpg , .gif , .png , .mp4 和 .mov ,所以我在我的import Dragula from 'react-dragula';
class Counter extends Component {
incrementCount(e) {
// I need to update the current state's count, and add 1 to it.
this.setState({
count: (this.state.count + 1),
})
}
decrementCount(e) {
this.setState({
count: (this.state.count - 1),
})
}
render() {
const { count } = this.props
const { decrementCount } = this.props
const { incrementCount } = this.props
const { nameof } = this.props
const { text, isDragging, connectDragSource, connectDropTarget } = this.props;
const opacity = isDragging ? 0 : 1;
return (
<div className='container' style={{ ...style, opacity }} ref={this.dragulaDecorator}>
<CountCell>
<Row style={{ alignItems: 'center' }}>
<Col>
<CountButton
onClick={incrementCount}>
<Icon
name="icon" className="fa fa-plus score-icon"
/>
</CountButton>
</Col>
<Col >
<ScoreName>{nameof}</ScoreName>
</Col>
<Col >
<Score>{count}</Score>
</Col>
<Col>
<CountButton
onClick={decrementCount}>
<Icon
name="icon" className="fa fa-minus score-icon"
/>
</CountButton>
</Col>
</Row>
</CountCell>
</div>
)
}
dragulaDecorator = (componentBackingInstance) => {
if (componentBackingInstance) {
let options = {};
Dragula([componentBackingInstance], options);
}
};
}
Counter.propTypes = {
// We are going to _require_ a prop called "count". It _has_ to be a Number.
count: PropTypes.number.isRequired,
// We are going to _require_ a prop called "incrementCount". It _has_ to be a Function.
incrementCount: PropTypes.func.isRequired,
// We are going to _require_ a prop called "decrementCount". It _has_ to be a Function.
decrementCount: PropTypes.func.isRequired,
nameof: PropTypes.string.isRequired,
}
export default Counter;
上使用accept
选项,如下所示:
input type="file"
这基本上很好用,但Firefox似乎忽略了<input name="message[file]" accept="image/jpeg,image/png,image/gif,video/mp4,video/quicktime" type="file">
MIME类型,文件对话框显示 .mov 文件不可用。所有其他接受的文件类型都可用。
当我使用video/quicktime
作为接受的文件类型时,我可以选择.mov文件,但我想将视频上传限制为 .mp4 和 .mov < / em>的。根据我的研究{。{1}}是.mov文件的正确MIME类型,WebKit-Browsers可以很好地使用它。为什么Firefox不接受.mov文件?
答案 0 :(得分:1)
HTML5标准仅支持MP4,WebM和Ogg视频。从Firefox 45开始,视频/ quicktime内容类型被视为MP4媒体,由内置的HTML5视频播放器处理。但是MOV文件可以包含各种不同的编码,它们并不都是MP4。