我在使用nodeJS和Angular上传文件时遇到问题.
我找到了解决方案,但它只与Ajax有关,我不知道.有可能没有吗?
使用以下代码我收到此错误:
POST http://localhost:2000/database/sounds 413 (Payload Too Large)
Run Code Online (Sandbox Code Playgroud)
码:
HTML:
<div class="form-group">
<label for="upload-input">This needs to be a .WAV file</label>
<form enctype="multipart/form-data" action="/database/sounds" method="post">
<input type="file" class="form-control" name="uploads[]" id="upload-input" multiple="multiple">
</form>
<button class="btn-primary" ng-click="uploadSound()">UPLOAD</button>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
$scope.uploadSound = function(){
var x = document.getElementById("upload-input");
if ('files' in x) {
if (x.files.length == 0) {
console.log("Select one or more files.");
} else {
var formData = new FormData();
for (var i = 0; i < x.files.length; i++) {
var file = …Run Code Online (Sandbox Code Playgroud)