这是我的代码:
var previewNode = $("#template");
previewNode[0].id = "";
var previewTemplate = previewNode.parent().html();
previewNode.remove();
var documentsDropzone = new Dropzone("#AddDocumentModal #AddFiledropzoneForm", {
url: '/Admin/Admin/SaveTempFile/',
previewTemplate: previewTemplate,
previewsContainer: "#documentpreviews",
clickable: "#dropzonePreviewZone",
accept: function (file, done) {
$('#add-Document-submit').prop('disabled', false);
var fileType = file.name.split('.').pop().toLowerCase();
var isValidFileType = fileType == 'docx' || fileType == 'doc' || fileType=='pdf';
if (!isValidFileType) {
$('#add-Document-submit').prop('disabled', true);
documentsDropzone.disable();
$('.dropzone-add-document-error-message').show();
}
else {
$('#documentpreviews').show();
done();
}
}
});
当我上传小尺寸的文件时,一切都很好。但是当我尝试上传大小超过5 mb的文件时,我收到了这样的错误500 (Internal Server Error)
。
这是HTML代码:
<div id="dropzonePreviewZone" class="dz-default dz-message default-view-dropzone-css">
<span class="glyphicon glyphicon-open upl-img dropzone-glyphicon-upload"></span>
<br/>
<span class="drop-text">Drop files here or click to upload</span>
</div>
<div class="files" id="documentpreviews"></div>
<div class="dropzone-add-document-error-message">
<div class="dropzone-error-div"><img src="@Links.Content.images.Declined_png" alt=""/></div>
<div class="dropzone-error-div dropzone-error-message"><p>Error! Files of this format are not accepted!</p></div>
<button class="close-dropzone-error-message dropzone-error-div"><img src="~/Content/images/delete_icon.png" alt=""/>
</button>
</div>
<div class="files" id="logopreviews">
<div id="template" class="file-row">
<div class="dropzone-elements-result-upload succes-dropzone-file-upload-body">
<img src="@Links.Content.images.Approved_png" alt=""/>
<span class="name" data-dz-name></span>
(<span class="size" data-dz-size></span>)
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"
aria-valuenow="0">
<div class="progress-bar progress-bar-success" data-dz-uploadprogress></div>
</div>
</div>
<button class="remove-Temp-File dropzone-elements-result-upload"><img src="~/Content/images/delete_icon.png"
alt=""/></button>
</div>
</div>
任何人都可以帮助我吗?我不明白我做错了什么。
答案 0 :(得分:1)
您必须编辑php.ini文件,因为文件的最大大小很小。在你的php ini中更改upload_max_filesize
的值。此外,更改maxRequestLength
有时会导致此错误。我在上传巨大的XML文件时面临同样的问题
答案 1 :(得分:0)
问题是由于权限所致。 通过将权限设置为775个上载目录解决了问题,然后解决了我的问题。