当我试图上传图片时,我得到了错误。我搞不懂为什么这件事一直给我一个问题。
Uncaught:$(.).uploadify不是函数

我的观点:
@model CRM.DataModel.Entities.Dictionary.TrainingType
@{ ViewBag.Title = "Edit"; }
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<input type="hidden" class="form-control" value="@Model.Id" name="Id">
<div class="mb-3">
<label for="exampleInputCarName" class="form-label">Name</label>
<input type="text" class="form-control" id="exampleInputCarName" value="@Model.Name" name="Name">
</div>
<div>
Click Select files to upload files.
<input type="file" name="file_upload" id="file_upload" />
</div>
<div id="uploaded"></div>
<button type="submit" class="btn btn-primary">Save</button>
<script type="text/javascript" src="@Url.Content("~/Content/UploadifyContent/jquery.uploadify.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/UploadifyContent/jquery.uploadify.min.js")"></script>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/UploadifyContent/uploadify.css")" />
}
@section Scripts
{
<script type="text/javascript">
$(document).ready(function () {
$('#file_upload').uploadify({
'swf': "@Url.Content("~/Content/UploadifyContent/uploadify.swf")",
'cancelImg': "@Url.Content("~/Content/UploadifyContent/uploadify-cancel.png")",
'uploader': "@Url.Action("Upload", "TrainingType")",
'onUploadSuccess' : function(file, data, response) {
$("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />");
}
});
});
</script>
}我必须更新我的要求并展示出来:



发布于 2021-11-10 11:58:39
按以下顺序加载脚本标记以解决此问题
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadify.min.js" type="text/javascript"></script>由于插件是jQuery的扩展,所以先加载jquery,然后加载插件,应该可以解决这个问题。
参考:https://github.com/RonnieSan/uploadify/blob/master/index.php
https://stackoverflow.com/questions/69912408
复制相似问题