English 中文(简体)
<input category=“file” 接受=“application/pdf> 不从事hr和roid
原标题:<input type="file" accept="application/pdf"> Does not work on chrome android

在我的网站上,我有这段话。 在我马奇和我看来,在我点击时,我会看到一个窗户,我可以选择一个档案,只能选择一个。 国防军有能力; 但是,当我从我的roid星座上看一页时,我可以选择档案或照相机,我可以选择哪一种档案。

是否还有办法使这项工作在安乐堡进行?

<input class="form-control" name="document_upload" type="file"
                                   accept=".pdf" required id="document_upload">
问题回答

This is the expected behaviour in Chrome for Android according to caniuse: https://caniuse.com/input-file-accept

根据格式类型提供适当的档案地点/投入,但不妨碍选择其他档案。

You can add this simple validation to ensure that the user selects the correct file type via JavaScript:

<input class="form-control" name="document_upload" type="file" accept=".pdf" required id="document_upload">

<script>
document.getElementById( document_upload ).addEventListener( change , function() {
    const fileInput = this;
    const selectedFile = fileInput.files[0];
    
    if (selectedFile) {
        if (selectedFile.type ===  application/pdf ) {
            // Valid file
        } else {
            // Invalid file
            alert( Please, select a PDF file. );
            fileInput.value =   ;
        }
    }
});
</script>

象寡妇这样的台 Desktop不应该是低等/无不同的能力,因此我也能够卸下任何档案。

“entergraph

I can edit /rename the filename to a .pdf and that will bypass any filename checker. and even if I check the magic header for %PDF that too can be spoofed. so the best way to tell you have a PDF uploaded is not run it, but analyse for trojan contents.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签