您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> js >> 正文

谈一下文件上传

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-27 我要参与讨论

  amp; (b[1] == 45) && (b[2] == 45) && (b[3] == 45) && (b[4] == 45)) {

break;

} else {

fieldValue.append(s);

}

}

fields.put(fieldName, fieldValue.toString());

}

if (!successful)

break;

}

}

//取得表单元素值

public String getFieldValue(String fieldName) {

if (fields == null || fieldName == null) {

return null;

}

return (String) fields.get(fieldName);

}

//取得上传文件数

public int getCount() {

return count;

}

//取得目标路径

public String getObjectPath() {

return objectPath;

}

//取得源文件名

public String[] getSourceFile() {

return sourceFile;

}

//取得目标文件名

public String[] getObjectFileName() {

return objectFileName;

}

//取得上传状态描述

public String[] getDescription() {

return description;

}

//判断上传文件的类型

private boolean canTransfer(int i) {

suffix[i] = suffix[i].toLowerCase();

//这个是用来传图片的,各位可以把后缀名改掉或者不要这个条件

if (sourceFile[i].equals("") || (!(canSuffix.indexOf("."+suffix[i])>=0))) {

description[i] = "ERR: File suffix is wrong.";

return false;

}

else {

return true;

}

}

//上传文件转换

private void transferFile(int i) {

String x = Long.toString(new java.util.Date().getTime());

try {

objectFileName[i] = x + "." + suffix[i];

FileOutputStream out = new FileOutputStream(objectPath + objectFileName[i]);

int a = 0;

int k = 0;

long hastransfered = 0; //标示已经传输的字节数

String s = "";

while ( (a = sis.readLine(b, 0, b.length)) != -1) {

s = new String(b, 0, a);

if ( (k = s.indexOf("Content-Type:")) != -1) {

break;

}

}

sis.readLine(b, 0, b.length);

while ( (a = sis.readLine(b, 0, b.length)) != -1) {

s = new String(b, 0, a);

if ( (b[0] == 45) && (b[1] == 45) && (b[2] == 45) && (b[3] == 45) && (b[4] == 45)) {

break;

}

out.write(b, 0, a);

hastransfered += a;

if (hastransfered >= size) {

description[count] = "ERR: The file " + sourceFile[count] +

" is too large to transfer. The whole process is interrupted.";

successful = false;

break;

}

}

if (successful) {

description[co

上一页  [1] [2] [3] [4] 下一页

在google里搜索更多谈一下文件上传

Google
Web www.51ec.org
  • 上一篇信息学院:

  • 下一篇信息学院:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    我来说两句 对此文章发表了评论
      昵 称: *必填    ·注册用户·
      评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
    评 论
    内 容

     
    评论列表 (最新 评论仅限网友观点!)

    推荐文章
  • 此栏目下没有推荐信息学院
  • 供求信息




    | 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明