2014-09-01 85 views
0

我正在使用http://filedropjs.org/#jquery在我的网页上实现文件放置功能。如何获得服务器对FileDrop.js jQuery接口的响应?

以下为示例代码的文档:

$('<div><p>Drop something here...</p></div>') 
    .appendTo(document.body) 
    .filedrop() 
    .on('fdsend', function (e, files) { 
    // Occurs when FileDrop's 'send' event is initiated. 
    $.each(files, function (i, file) { 
     file.sendTo('upload.php') 
    }) 
    }) 
    .on('filedone', function (e, file) { 
    // Occurs when a File object has done uploading. 
    alert('Done uploading ' + file.name + ' on ' + this.tagName) 
    }) 

我怎样才能读取服务器的上“filedone的回应?对象e或文件似乎不包含它(用JSON.stringify检查)。我想upload.php重命名并保存文件,并将新文件名发送回网页。

回答

0

好了,所以这可能只是通过增加XHR对象的“filedone”功能来实现:

.on('filedone', function (e, file, xhr) {             
    var serverResponse = xhr.responseText; 
} 
相关问题