file upload,changing the all files in the popup wi

2019-06-13 19:36发布

问题:

I want to change the deafult file selection limited to .pdf files only instead of All Files(*.*) in the file open window. Any ideas on how to implement it?

Example:

回答1:

There are a couple ways you can do this and restrict the user to select certain file types only, which is PDF in your case.

Here are two ways you can implement it via PHP/Javascript, but these are a bit of an overhead and will require a bit of coding if you are already not using these WYSIWYG editors.

TinyMCE - http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser

CKEditor - http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)/Custom_File_Browser

Hope it helps.



回答2:

other way. You can use Uploadify.

Uploadify

it is flash base application. Working fine every browser.



回答3:

This is possible for Chrome only with the new accept attribute of HTML5:

<input type="file" name="myfile" accept=".pdf" />

Live test case.

IE does not and will probably never support that attribute, Firefox supports the attribute but it can only be for image, audio or video files and not PDF.

For cross browser support you will have to build browser extension/plugin for each browser or use Java/Flash.