我正在尝试在实际上传之前获取上传的文件名。所以我尝试使用onBeforeUpload
事件并将其记录到控制台但没有任何返回。
下面是我使用的代码。我做错了什么?
谢谢
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Uppy</title>
<link href="https://releases.transloadit.com/uppy/v1.28.1/uppy.min.css" rel="stylesheet">
</head>
<body>
<div id="drag-drop-area"></div>
<script src="https://releases.transloadit.com/uppy/v1.28.1/uppy.min.js"></script>
<script>
const uppy = Uppy.Core({
debug: true,
autoProceed: true,
restrictions: {
maxFileSize: 2147483647,
maxNumberOfFiles: 5,
minNumberOfFiles: 1,
allowedFileTypes: ['.pdf', '.png', '.jpg', '.jpeg', '.gif']
}
})
.use(Uppy.Dashboard, {
inline: true,
target: '#drag-drop-area'
})
.use(Uppy.Tus, {endpoint: 'https://tusd.tusdemo.net/files/'})
onBeforeUpload: (files) => {
console.log("this is event before upload");
}
uppy.on('complete', (result) => {
console.log('Upload complete! We’ve uploaded these files:', result.successful)
})
</script>
</body>
</html>