请问如何制作ACTIVEX插件将本地文件内容读入到网页中的的一个字段,文件是无类型的!
网页:
<OBJECT
id="upload"
classid="clsid:DDD47460-8145-4A3C-9CE9-35125ABD4303"
codebase="http://TZP/uploadProj1.cab#version=1,0,5,0"
width=350
height=250
align=center
hspace=0
vspace=0
>
</OBJECT><input type="file" onClick="alert(upload.getFile(file.value))" name="file" >
DELPHI:
function getFile(filepath: String):String;
var thestream:TmemoryStream;
var upfile:File;
begin
thestream:=TmemoryStream.Create();
thestream.loadFromFile(filepath);
Result:= thestream;//不知如何写!!!
end;
网页:
<OBJECT
id="upload"
classid="clsid:DDD47460-8145-4A3C-9CE9-35125ABD4303"
codebase="http://TZP/uploadProj1.cab#version=1,0,5,0"
width=350
height=250
align=center
hspace=0
vspace=0
>
</OBJECT><input type="file" onClick="alert(upload.getFile(file.value))" name="file" >
DELPHI:
function getFile(filepath: String):String;
var thestream:TmemoryStream;
var upfile:File;
begin
thestream:=TmemoryStream.Create();
thestream.loadFromFile(filepath);
Result:= thestream;//不知如何写!!!
end;
解决方案 »
- 《Object Pascal》与《Delphi》这2个是什么?
- 如何在状态栏中的各个子项中添加图片
- Delphi+Oracle如何查找一条记录
- dbgird中如何修改选定数据?
- dephi如何实现显示所有文件及文件夹到不显示隐藏文件及文件夹的切换?
- 各位,有听过这个公司吗?(广州领华科技有限公司)
- 请教大家一个关于DBComboBox的问题 先谢过!! 在线等 急用
- 怎么获取.exe文件的图标。
- 各位,www.delphi6.onchina.net开通了delphi6论谈,现在急招班竹。
- 三层结构的更新数据问题
- Delphi的前途好担忧.我对你没有信心~请大家讨论(进者有分)
- 如何把Image中的图像伸缩到一定的尺寸大小再复制到剪帖板上???
<input type="button" name="a" onClick="alert('upload.getFile(file.value)')" >
<input type="file" name="file">
DELPHI函数改成下面这个,
function getFile(filepath: String):integer;
var
srcTypedFile: Integer;
BytesRead: Integer;
Buffer: array[0..15] of byte;
begin
srcTypedFile := FileOpen(filepath, fmOpenRead);
try
repeat
BytesRead := FileRead(srcTypedFile, buffer[0], SizeOF(buffer));
until BytesRead<SizeOf(buffer);
finally
FileClose(srcTypedFile);
end;
Result:=srcTypedFile;
end;仍然无法处理!!!