當我嘗試上傳圖片時出現錯誤。我不明白為什么我這總是給我一個問題。

我的看法:
@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>
}
我必須更新我的詢問并顯示它:


uj5u.com熱心網友回復:
在呼叫該函式之前,請確保腳本庫包含在 DOM 中。
uj5u.com熱心網友回復:
按以下順序加載腳本標簽以解決此問題
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadifive.min.js" type="text/javascript"></script>
由于插件是jquery的擴展,先加載jquery再加載插件應該可以解決問題
參考:https : //github.com/RonnieSan/uploadify/blob/master/index.php
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/355054.html
上一篇:javascript:空陣列值
下一篇:根據計算出的數字顯示不同的影像
