-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Frequently Asked Questions
It is possible to upload files up to 4 GB with the jQuery File Upload plugin.
By making use of Chunked file uploads (with chunks smaller than 4GB), the potential file size is unlimited.
The restriction of 4 GB is due to some browser limitations, which might be fixed in future updates to those browsers:
Firefox bug references:
https://bugzilla.mozilla.org/show_bug.cgi?id=215450
https://bugzilla.mozilla.org/show_bug.cgi?id=660159
Chrome bug references:
http://code.google.com/p/chromium/issues/detail?id=139815
If you define the url (and probably paramName) Options, you can call the plugin on any element - no form or file input field required - and the drag&drop functionality will still work.
To support browsers without XHR file upload capabilities, a file input field has to be part of the widget, or defined using the fileInput option.
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.
Lower the previewMaxSourceFileSize setting or remove the "preview" class from the upload template to avoid rendering large preview images, which have the potential to block the main JS thread.
Invoking a click event on the file input field programmatically is not supported across browsers - see Style Guide.
However, another file input button can be used to trigger the file selection and passed as parameter to the fileupload add or send API:
$('#some-file-input-field').bind('change', function (e) {
$('#fileupload').fileupload('add', {
files: e.target.files || [{name: this.value}],
fileInput: $(this)
});
});
Just make use of jQuery's each method to set the this keyword to the element node:
$('#fileupload').each(function () {
$(this).fileupload({
fileInput: $(this).find('input:file')
});
});
Just remove the multiple attribute from the file input:
<input type="file" name="files[]">
Note that users can still drag&drop multiple files. To enforce a one file upload limit, you can make use of the maxNumberOfFiles option (see Options).
This has been built-in and is currently supported by the latest versions of Mozilla Firefox and Google Chrome. Please have a look at the process Options.
Yes, with the latest version of Google Chrome it is possible.
It is also possible to allow selecting a folder (instead of files) via the file input element by adding browser-vendor specific "directory" attributes, though this seems to be only supported in Google Chrome so far:
<input type="file" name="files[]" multiple directory webkitdirectory mozdirectory>
See also issue #573.
This is called a protocol relative url and a perfectly valid way to define a resource, relative to the current URL protocol.
This ensures that the referenced scripts are loaded via the same protocol as the current page, which avoids security notifications when loading resources via unencrypted HTTP on a page loaded via HTTPS.
However, it also requires that the current protocol is either "http:" or "https:" and will not work on a "file:" url.
See also issue #514 as well as pull requests #722, #833 and #1789.
The template will be rendered for each add call.
As long as the option singleFileUploads is set to true (which is the default), multiple selects/drops get split up into single add calls, so the index will always be 0.
Please see the comments for Issue #893.
See Firefox Bug #642463.
This bug has been addressed with commit f60bbfb2546bc08fe9538d3af56be8d07e634675.
The plugin makes use of metric prefixes in conformance of the International System of Units. This is the same unit system that is used by hard drive manufacturers and e.g. the Mac OSX operating system to report hard drive capacities. Unfortunately, the terms "kilobytes", "megabytes", etc. have historically been used in ambiguous meanings. Please have a look at the Binary Prefix article on Wikipedia for background information.
Please see issue #1976
The file upload plugin makes use of an Iframe Transport module for browsers like Microsoft Internet Explorer and Opera, which do not yet support XHR file uploads.
Iframe based uploads require a Content-type of text/plain or text/html for the JSON response - they will show an undesired download dialog if the iframe response is set to application/json.
Please have a look at the Content-Type Negotiation section of the Setup instructions.
This is due to how the response content is parsed when using the iframe transport, which is required by Internet Explorer.
Have a look at an explanation and solution from user espeoneefi.
Your JSON response is probably not valid JSON.
You can test your JSON response for validity on jsonlint.com.
To retrieve the JSON response, make use of the network tab of your browser development tools (e.g. Google Chrome's and Safari's developer console or Firebug).
You probably have a server-side setting preventing you to upload larger files.
Try adding the following to a .htaccess file in the php directory:
php_value upload_max_filesize 9G
php_value post_max_size 9G
php_value max_execution_time 200
php_value max_input_time 200
php_value memory_limit 256M
If this doesn't work, try creating a php.ini file in the php directory and add the following lines:
upload_max_filesize 9G
post_max_size 9G
max_execution_time 200
max_input_time 200
memory_limit 256M
If this also doesn't work, contact your hosting provider.
If your non-ASCII file names get uploaded with strange characters like ä, ö or ü you probably need to apply the utf8-decode() method on the file names of uploaded files, e.g. by overriding the trim_file_name method:
<?php
require('upload.class.php');
class CustomUploadHandler extends UploadHandler {
protected trim_file_name($name, $type, $index) {
$name = utf8_decode($name);
return parent::trim_file_name($name, $type, $index);
}
}
$upload_handler = new CustomUploadHandler();
Depending on your server-environment, you might have to do Unicode normalization, to achieve the same binary representation of strings with Unicode characters.
See also issue #1339.
The File Upload plugin will properly handle HTTP response codes when the browser supports XHR file uploads. It even displays the correct error message, e.g. "Error: Service Unavailable" for the following HTTP header :
HTTP/1.0 503 Service Unavailable
However, for browsers without support for XHR file uploads - which includes Internet Explorer before IE10 - the Iframe Transport is used and there is no way to retrieve the HTTP status code from an iframe load event.