我尝试为头像图像创建拖放功能.我想要有人拖入盒子的文件; 上传到目录:'/ images/profile/$ username'.
这是我的代码:
<div class='fileDrop'>
<span id='fileDropTarget'>Drag your files here</span>
</div>
<script>
function fileSetUploadPercent(percent) {
var uploadString = "Uploaded " + percent + " %";
$('#fileDropTarget').text(uploadString);
}
function fileUploadStarted(index, file, files_count) {
fileSetUploadPercent(0); //set the upload status to be 0
}
function fileUploadUpdate(index, file, currentProgress) {
var string = "index = " + index + " Uploading file " + file.fileName + " size is " + file.fileSize + " Progress = " + currentProgress;
$('#status').text(string);
fileSetUploadPercent(currentProgress);
} …Run Code Online (Sandbox Code Playgroud)