- 论坛徽章:
- 0
|
这是我关于上传文件的一段代码,为何上传文件大于32765时,文件FILEREAD()出来的总是比FIELLENGTH()要多出几百K的大小?帮忙看下,或者说关于上传文件的程序是怎么写的,给我个参考,多谢!
string ls_path,ls_name
ls_path = string(sle_3.text)
long ls_len,i,j
for i = 1 to parent.dw_1.rowcount()
blob ls_file,ls_pic
long li_i
ls_name = parent.dw_1.object.file_name
IF NOT (fileexists(ls_path + '\'+ ls_name)) THEN //17
messagebox("提示",ls_name + "不存在,请检查!")
RETURN
END IF
// messagebox("1",ls_path + '\'+ ls_name)
ls_len = filelength(ls_path + '\'+ ls_name)
li_I = FILEOPEN(ls_path + '\'+ ls_name,STREAMMODE!)
if li_I <> -1 then
// Yield()
FOR j=1 TO CEILING(ls_len/32765)
FILEREAD(LI_I,ls_pic)
ls_file = ls_file+ls_pic
// FILESEEK(LI_I,32765*j,FROMBEGINNING!)
NEXT
end if
FILECLOSE(LI_I)
if ls_len = len(ls_file) then
UPDATEBLOB sys_files set file_string = :ls_file where file_name = :ls_name;
if sqlca.sqlcode = 0 then
commit;
parent.dw_1.object.file_path = '上传成功!'
else
rollback;
messagebox('提示:','上传文件'+ls_name+ '出错!')
parent.dw_1.object.file_path = '上传失败!'
exit
return
end if
else
messagebox('提示:','读取文件'+ls_name+ '出错!')
messagebox('提示:','ls_len='+ string(ls_len)+',len(ls_file)'+string(len(ls_file)))
parent.dw_1.object.file_path = '读取文件'+ls_name+ '出错!'
exit
return
end if
parent.dw_1.accepttext()
next
结果总是LEN(LS_FILE) > FILELENGTH() |
|