프론트 엔드에서 Plupload를 사용하여 파일 업로드를 구현하고 멀티 파트/폼 업로드를 위해 멀더 미들웨어로 백엔드에서 nodej를 표현합니다. 이 가능한 예는 현재 없다, 그래서 이것은 내가 지금까지 무엇을 가지고 있습니다 :청크와 함께 묵터를 사용하여 익스프레스에서 plupload를 처리하는 방법은 무엇입니까?
HTML 프론트 엔드 : 그것은 기본적으로 단지 plupload 빠른 시작 가이드
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
</head>
<ul id="filelist"></ul>
<br />
<div id="container">
<a id="browse" href="javascript:;">[Browse...]</a>
<a id="start-upload" href="javascript:;">[Start Upload]</a>
<br />
<pre id="console"></pre>
</div>
<script src="/plupload/js/plupload.full.min.js"></script>
<script type="text/javascript">
var uploader = new plupload.Uploader({
browse_button: 'browse', // this can be an id of a DOM element or the DOM element itself
url: '/upload'
});
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
var html = '';
plupload.each(files, function(file) {
html += '<li id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></li>';
});
document.getElementById('filelist').innerHTML += html;
});
uploader.bind('UploadProgress', function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
});
uploader.bind('Error', function(up, err) {
document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
});
document.getElementById('start-upload').onclick = function() {
uploader.start();
};
</script>
</html>
: http://www.plupload.com/docs/v2/Getting-Started
백엔드 사용하여 노드 표현한다. 그래서 여기에 사용하기위한 최소 작업 버전까지 내 코드를 손질 :
const path = require('path');
const express = require('express');
var multer = require('multer');
var upload = multer({ dest: 'uploads/' });
// Create express
const app = express();
app.use(express.static('public'));
app.post('/upload', upload.array('file'), function(req, res){
console.log(req.files);
})
app.listen(3000, function() {
console.log('App running...');
});
기본적으로, multer 패키지와 정적 파일을 봉사와 단지 일반 고속 응용 프로그램.
질문 : 프런트 엔드 및 NodeJS에 Plupload를 사용하여 파일을 업로드하려면 어떻게
백엔드에 (명시 적, multer 사용)? 또한 청킹을 지원해야합니다.
안녕 데이비드, 어떤 생각을 표현하는 방법을 "말하기"를 plupload로 지정 하시겠습니까? – kosinix
@kosinix 네, 쉽게 할 수 있습니다. 업데이트 된 답변 확인 (** 업데이트 ** 제목 아래) –