Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get blueimp/jQuery.fileupload plugin to work

Am trying use this jQuery plugin for cross domain image uploads jQuery.fileupload

I think the plugin uses require.js, which i have already included because i use it load javascript code for my page. The plugin doesnt seem to required that i include require.js, but when i test my page i get this error

Uncaught Error: Mismatched anonymous define() module: function ( $, undefined ) { http://requirejs.org/docs/errors.html#mismatch

Can someone please point me in the right direction

like image 346
MrFoh Avatar asked Apr 09 '12 20:04

MrFoh


People also ask

How to use jQuery File Upload plugin?

This jQuery File Upload will work like the demo shown below: Let us start with the implementation. First download the plugin from GitHub in your drive, copy it’s css and js folders and paste them inside your application’s wwwroot folder. Check the below image which explains this.

When is the upload action called when the plugin uploads the files?

Explanation: The Upload action is called when the plugin uploads the files. This action has a parameter – IFormFile files, which gets the uploaded files from the view by the technique called Model Binding.

What is the use of iformfile in the upload action?

Explanation : The Upload action is called when the plugin uploads the files. This action has a parameter – IFormFile files, which gets the uploaded files from the view by the technique called Model Binding. I save these files inside the uploads folders and this folder is inside the wwwroot folder of the application.

How to install a plugin from GitHub?

First download the plugin from GitHub in your drive, copy it’s css and js folders and paste them inside your application’s wwwroot folder. Check the below image which explains this.


Video Answer


2 Answers

You don't need to use Requirejs to use jQuery File Upload.

Simply make sure you include the required files in the right order:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="js/vendor/jquery.ui.widget.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="js/jquery.fileupload.js"></script>
<script>
$(function () {
    $('#fileupload').fileupload({
        // your options
    });
});
</script>
like image 50
Jesús Carrera Avatar answered Oct 05 '22 05:10

Jesús Carrera


I am glad that I am not alone here. This issue took me hours and here is the answer for you,

This is all about the order of loading those JavaScript files. You must include the files in the following order or it won't work.

  • jquery-min.js
  • jquery.ui.widget.js
  • jquery.iframe-transport.js
  • jquery.fileupload.js
  • jquery.fileupload-ip.js
  • jquery.fileupload-ui.js
  • require-min.js (this must be the last one to be included)
like image 20
RHE Avatar answered Oct 05 '22 03:10

RHE