上传文件的处理细节(3)
ProgressListener显示上传进度
ProgressListenerprogressListener = new ProgressListener() {
public void update(long pBytesRead, longpContentLength, int pItems) {
System.out.println("到现在为止, " + pBytesRead + " 字节已上传,总大小为 "
+ pContentLength);
}
};
upload.setProgressListener(progressListener);
以KB为单位显示上传进度
long temp =-1; //temp注意设置为类变量
long ctemp =pBytesRead /1024;
if (mBytes ==ctemp)
return;
temp =mBytes;
多个文件上传的javascript编码
技巧:
每次动态增加一个文件上传输入框,都把它和删除按纽放置在一个单独的div中,并对删除按纽的onclick事件进行响应,使之删除删除按纽所在的div。
如:
this.parentNode.parentNode.removeChild(this.parentNode);