I have the following problem
I'm using MVC (C #) and I need to upload a document in general (.doc, .pdf, .png, etc.)
I'm using the FileUpload library and with jquery 3.1
In the example standard the component has, it's jquery 1.9 (I do not know if it can have something to do) and it works normally.
I get the error below
TypeError: $ (...) fileupload is not a function
the code itself is below this page
<p>
<input type="text" id="tbx-file-path" value="No file chosen..." readonly="readonly" />
<span class="btn btn-success fileinput-button">
<span>Select file...</span>
@Html.TextBoxFor(m => m.MyFile, new { id = "fu-my-simple-upload", type = "file" })
</span>
</p>
<p><a class="btn btn-primary" href="#" id="hl-start-upload">Start Upload</a></p>
@section scripts{
<script type="text/javascript">
var jqXHRData;
$(document).ready(function () {
'use strict';
$('#fu-my-simple-upload').fileupload({
url: '/File/UploadFile',
dataType: 'json',
add: function (e, data) {
jqXHRData = data
},
done: function (event, data) {
if (data.result.isUploaded) {
$("#tbx-file-path").val("No file chosen...");
}
else {
}
alert(data.result.message);
},
fail: function (event, data) {
if (data.files[0].error) {
alert(data.files[0].error);
}
}
});
});
$("#hl-start-upload").on('click', function () {
if (jqXHRData) {
jqXHRData.submit();
}
return false;
});
$("#fu-my-simple-upload").on('change', function () {
$("#tbx-file-path").val(this.files[0].name);
});
</script>
}