I use yii2 and blueimp jQuery File Upload Plugin for upload multiple files at my site.
How I can disable preview for not image files?
I found this on the Project website on github:
You can use the accept attribute of the file input field to limit the file type selection, though this seems to be supported only on Google Chrome and Opera.
An example limiting files to PNG images:
<input type="file" name="files[]" accept="image/png" multiple>
Note that this will not limit files added by drag&drop and is not supported across all browsers.
If you must upload files with a specific extension you can restric the upload.
Related
I am using a html input tag with type="file" as in this snippet.
Unfortunately it is not possible to drag the opening file explorer around.
Tested on: Chrome v80 MacOS
Is it possible to make the file dialog draggable?
<input type="file">
No, it isn't. That's just how your browser / OS implement file picker dialogs.
using this for the accept field in my file input:
application/zip,application/x-zip,application/x-zip-compressed,application/octet-stream
Result:
Internet Explorer: Only shows .zip. Yay.
FireFox: shows all files, but I can change dropdown to only show .zip. Can I change .zip to be the default view somehow?
Chrome: shows .zip and .exe. How do I exclude .exe?
I know chrome is technically right, but I'm trying to be user friendly here.
try
<!-- (IE 10+, Edge, Chrome, Firefox 42+) -->
<input type="file" accept=".zip,.rar,.7zip" />
<input type="file" accept="zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed">
application/octet-stream is the "catch-all" bucket. It's the default mime-type if the filename has no extension to help determine it. It's also the source of your EXE representation in Chrome, I'm guessing.
Limit file format when using <input type="file">?
You can also try reducing it with the "accept" attribute on the INPUT/File. That link above also has a link to a JSFiddle page you can play and test with.
I have a file to upload in my page.
<input type="file" id='fFile' name="template"/>
But I want it to show only rptdesign file. Could anyone please help?
Also I have added
<input type="file" id='fXls' name="template"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>
for xlsx but when the dialog box appears with All files and Xlsx in the dropdown but all All Files selected. Can Xlsx be selected?
Look into MIME_Types:
<input accept="audio/*|video/*|image/*|MIME_type">
A list of different media MIME-types here!
Note: The accept attribute of the input tag is not supported in Internet Explorer 9 and earlier versions.
EDIT
In your Tomcat configuration files, go to your web.xml.
If you scroll down you will find mime-type mapping. Here you can specify extensions for the server!
Example (web.xml):
<mime-mapping>
<extension>asx</extension>
<mime-type>video/x-ms-asf</mime-type>
</mime-mapping>
Hopefully that helps!
In chrome its working fine and I found out that firefox are still working on it.
https://bugzilla.mozilla.org/show_bug.cgi?id=826185
I'd embedded a pdf file on my page. On some browsers it shows properly that pdf file but on some browser instead of showing that file it ask me to download that file.
One of the possible reason could be unavailability of plugin in the browser to display the file.
But I want that if it was unable to show do not ask the file to download.
URL for reference
You can use the https://docs.google.com/viewer to accomplish this.
All you do is enter the link and it wil generate a link
Use an iframe with that link to get it embedded
I want to allow users to select a local directory on a webpage (and then read all the files in the directory).
In Chrome I can add the webkitdirectory attribute to enable this functionality. According to a comment in this question and an answer to this question you should be able to do the same in firefox using mozdirectory but I am unable to get it to work.
I have tried the following in Firefox with no luck (works in Chrome):
<input type="file" id="files" name="files[]" multiple mozdirectory="" webkitdirectory="" directory="" />
My Firefox version is 10.0.
Are there any way for a user to select a directory for input in Firefox without requiring an add-on on the client-side (like Flash)?
Firefox doesn't have any API to upload directories yet (which is a shame)...not even in the nightly builds, so I don't think we will see support on this very soon. IE doesn't have one either. If you want to take advantage of this feature you must force the users to use Google Chrome (e.g. make them aware that upload directory is available only in Chrome).
A workaround would be to compress the directory in a .zip file and read it with the FileReader API. See https://stackoverflow.com/a/7842896/613453
Update
IE Edge now has support for this.
https://msdn.microsoft.com/en-us/library/mt574730(v=vs.85).aspx
Now you can upload directory using drag and drop with chrome
read this article you will get more info
http://updates.html5rocks.com/2012/07/Drag-and-drop-a-folder-onto-Chrome-now-available