0
I have the following problem
I am using MVC (C#) and I need to upload documents in general(. doc, . pdf , . png, etc)
I am using the Fileupload library and jquery 3.1
In the example pattern that the component has, it is jquery 1.9 (I don’t know if it can have something to do) and works normally.
I get the error below
Typeerror: $(...). fileupload is not a Function
the code itself of the page is below
<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>
}
It seems to me that the File Uploader library has not been loaded.
– Sam
Yes. But she’s on the project
– Diego Luiz de Brito
Make sure the libraries are in the right order, top to bottom. jQuery comes before all.
– Sam
All libraries are OK. I’m checking to see if you don’t have any jquery file conflicts
– Diego Luiz de Brito