내 프로젝트에 dropzone을 구현했습니다. 모두 잘 작동합니다. 브라우저가 페이지가 명확성을 요구할 때마다 브라우저가 오류를 던지기로 결정한 것을 제외하고는보기가 길어졌지만 아래의 HTML은 현재 양식 안에 있습니다 (어쨌든 문제가 발생하는지 확실하지 않음). 여기에 표시된 dropzone에 대한 하나의 참조는 dropzone.js가 번들 config 내에 한 번만 나타납니다.Dropzone.js already attached
오류 : (this.element.dropzone) (". 이미 부착 DROPZONE") 새로운 오류가 발생하는 경우
이이 내가
$(document).ready(function() {
$("div#UploadImage").dropzone({ url: '@Url.Action("SaveUploadedFile", "Person")' });
});
DROPZONE 만드는 방법 내보기
<div class="form-group">
<div class="col-xs-12 dropzone" id="UploadImage">
<input type="file" id="id-input-file-2" />
</div>
</div>
입니다
다음과 같은 내 컨트롤러
public ActionResult SaveUploadedFile()
{
bool success = true;
string fName = string.Empty;
try
{
foreach (var file in Request.Files.Cast<string>().Select(fileName => Request.Files[fileName]).Where(file => file != null))
{
fName = file.FileName;
if (file.ContentLength > 0)
{
// will write the rest of the code here
}
}
}
catch (Exception ex)
{
success = false;
}
return Json(success ? new { Message = fName } : new { Message = "Error in saving file" });
}
이제 코드에서 dropzone이 다시 초기화되어 위의 오류가 발생하는 위치를 알 수없는 컨트롤러 내 이미지를 검색 할 수 있습니다.
내 JQuery와 Daves 제안을 시도 후 UPDATE
이제이
$(document).ready(function() {
Dropzone.options.myAwesomeDropzone = false;
$("div#UploadImage").dropzone({
url: '@Url.Action("SaveUploadedFile", "Person")',
addRemoveLinks: true,
removedfile: function (file) {
var name = file.name;
$.ajax({
type: 'POST',
url: '@Url.Action("DeleteUploadedFile", "Person")',
data: "id=" + name,
dataType: 'html'
});
var ref;
return (ref = file.previewElement) != null ? ref.parentNode.removeChild(file.previewElement) : void 0;
},
maxFilesize: 2,
maxFiles: 12,
});
});
처럼 보인다하지만 아직 난 여전히 오류가 발생합니다.
자동 검색의 전원을 끄고
나는 이것을 시도하고 새 Jquery로 내 질문을 업데이트했지만 아직 오류가 발생합니까?!?! 나는 Dropzone –
젠체하는 나의 구현 위에 제안한 것을 넣었습니다 ... 그 대답을 얻었습니다. –