idhttpserver 下载文件
procedure TForm30.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
const
WEBROOT = 'C:\www';
const sb='C:\www\index.html';
var ss,s,s1,s3,s2:string; wenjian1,wenjian2,wenjian3:tstringlist; f1,f2,f3:string;
I: Integer;
var
RequestDocument:string;
begin
(* wenjian1:=tstringlist.Create;
if fileexists('c:\3fangan.txt') then
begin
wenjian1.LoadFromFile('c:\3fangan.txt');
wenjian1.Text:=trim(wenjian1.text);
end else
begin
{ s:='<html> <body>'+' ' +'</body></html>';
AResponseInfo.ContentText:=s;
exit; }
end;
//</br>
memo1.Lines.Add(ARequestInfo.Document) ;
memo1.Lines.Add(arequestinfo.Params.Values['t1']) ;
memo1.Lines.Add(arequestinfo.Params.Values['t2']);
f1:='-1';f2:='-1';f3:='-1';
f1:=ARequestInfo.Document ;
f2:=arequestinfo.Params.Values['t1'] ;
f3:=arequestinfo.Params.Values['t2'];
if f2='-1' then begin // 默认访问
//-----------------------换行 变 </br>
ss:='';
for I := 0 to wenjian1.Count -1 do
begin
if length(trim(wenjian1.Strings[i]))<1 then continue;
ss:=ss+wenjian1.Strings[i]+'上面是第'+inttostr(i)+'个推送'+'</br>';
end;
ss:=copy(ss,1,length(ss)-5);
// wenjian1.Text:=ss;
//======================换行 变 </br>
wenjian1.Free;
end;
if f2='qing0' then //清除数据
begin
wenjian1.Clear;
wenjian1.SaveToFile('c:\3fangan.txt');
wenjian1.Free;
ss:='';
end;
if f2='1' then
begin
f3:=httpdecode(ARequestInfo.FormParams);// 这个是 post 的内容
// showmessage(f3);
wenjian1.Add(f3);
wenjian1.SaveToFile('c:\3fangan.txt');
//-----------------------换行 变 </br>
ss:='';
for I := 0 to wenjian1.Count -1 do
begin
if length(trim(wenjian1.Strings[i]))<1 then continue;
ss:=ss+wenjian1.Strings[i]+'上面是第'+inttostr(i)+'个推送'+'</br>';
end;
ss:=copy(ss,1,length(ss)-5);
// wenjian1.Text:=ss;
//======================换行 变 </br>
wenjian1.Free;
// showmessage(ss);
end;
AResponseInfo.ContentEncoding:='utf-8';
AResponseInfo.ContentType := 'text/html; charset=gb2312';
s:='<html> <body>'+ss +'</body></html>';
AResponseInfo.ContentText:=s; *)
//<BUTTON onclick="open('c:\\','_blank','',false)">打开</BUTTON>
{
AResponseInfo.ContentEncoding:='utf-8';
AResponseInfo.ContentType := 'text/html; charset=gb2312';
ss:='<BUTTON onclick="open(''c:\\'',''_blank'','''',false)">打开</BUTTON> ';
s:='<html> <body>'+ss +'</body></html>';
AResponseInfo.ContentText:=s;
// aresponseinfo.ServeFile(AContext,'c:\');
AResponseInfo.ContentText:='c:\abc.txt' ; }
{
RequestDocument:=LowerCase(ARequestInfo.Document);
if RequestDocument='/' then
RequestDocument:='/index.html';
if FileExists(WEBROOT+RequestDocument) then
begin
AResponseInfo.ContentStream:=TFileStream.Create(WEBROOT+RequestDocument, fmOpenRead + fmShareDenyWrite);
end
else
begin
AResponseInfo.ResponseNo := 404;
end;
AResponseInfo.Server:='IIS/6.0';
AResponseInfo.CacheControl:='no-cache';
AResponseInfo.Pragma:='no-cache';
AResponseInfo.Date:=Now;
}
// AResponseInfo.ContentEncoding:='utf-8';
//AResponseInfo.ContentType := 'text/html; charset=gb2312';
//AResponseInfo.ContentDisposition:=Format('inline: filename="%s"',[ExtractFileName(s)]);
//AResponseInfo.CustomHeaders.Values['Content-Disposition'] :='attachment; filename="'+'192.168.0.101:12345/abc.txt'+'"';
//AResponseInfo.ServeFile(AContext,'192.168.0.101:12345/abc.txt');
//response
AResponseInfo.ContentType :='application/pdf';
//GetFileMIMEType
//AResponseInfo.ContentType := GetMIMEType(LocalDoc);
//application/x-rar-compressed
//aResponseInfo.ContentType := 'application/x-rar-compressed';
AResponseInfo.ServeFile(AContext,'c:\www\a.pdf');
end;
idhttpserver 下载文件的更多相关文章
- 怎样用idhttpserver代替IIS让用户浏览html或下载文件 http://bbs.csdn.net/topics/360248674
怎样用idhttpserver代替IIS让用户浏览html或下载文件 更多0分享到: 相关知识库: C# 虚拟现实(VR) Node.js 算法与数据结构 对我有用[0] 丢个板砖[0] ...
- Java下载文件(流的形式)
@RequestMapping("download") @ResponseBody public void download(HttpServletResponse respons ...
- 使用批处理文件在FTP服务器 上传下载文件
1.从ftp服务器根目录文件夹下的文件到指定的文件夹下 格式:ftp -s:[配置文件] [ftp地址] 如:ftp -s:c:\vc\ftpconfig.txt 192.168.1.1 建立一个 ...
- 通过form表单的形式下载文件。
在项目中遇到问题,要求动态拼接uri下载文件.但是由于项目的安全拦截导致window.location.href 和 window.open等新建窗口的方法都不行. 无意间百度到了通过form表单来下 ...
- SecureCRT上传和下载文件
SecureCRT上传和下载文件(下载默认目录) SecureCR 下的文件传输协议有ASCII .Xmodem .Ymodem .Zmodem ASCII:这是最快的传输协议,但只能传送文本文件. ...
- HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
今天,在vs2013中新建了一个placard.json文件,当我用jq读取它的时候,去提示404,直接在浏览器访问这个文件,提示: HTTP 错误 404.3 – Not Found 由于扩展配置问 ...
- FTP下载文件失败
这几天的定时任务下载文件的脚本失败了. 于是手工执行测试,发现报550 Permission denied. Passive mode refused. 意思就是被动模式下,没有权限获取文件. 解决方 ...
- 如何使用FileZilla上传和下载文件
一.使用FileZilla上传文件 1 打开 FileZilla 按照如下图所示,填写远程 Linux 的 IP ,用户名,密码,还有端口号(默认22) 2 选中左边需要上传的文件,然后拖到右边,等待 ...
- 开发板tftp下载文件
搭建过程: 1.安装相关软件包:tftpd(服务端),tftp(客户端),xinetd sudo apt-get install tftpd tftp xinetd 2.建立配置文件(蓝色的目录是可以 ...
随机推荐
- jsp自定义标签处理转义字符
sun公司提供的jstl虽然比较强大,但是开发中很难满足我们所有的需求,并且开发也禁止在jsp中写很多java代码,因此很多场景需要自己定义标签进行项目开发 sun提供的标签库引用方式:<%@t ...
- Vue+axios+Node+express实现文件上传(用户头像上传)
Vue 页面的代码 <label for='my_file' class="theme-color"> <mu-icon left value="bac ...
- 剑指offer学习读书笔记--二维数组中的查找
在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都是按照从上到下递增的顺序排序.请设计一个函数,输入这样的一个二维数组和一个整数,判断数组是否含有这个整数. 1 2 8 9 2 4 9 1 ...
- wepy_two
2.代码高亮WebStorm/PhpStorm(其他工具参见:wepy官网代码高亮) (1)打开Settings,搜索Plugins,搜索Vue.js插件并安装. (2) 打开Settings,搜索F ...
- 封装和private,this,super关键字的简单应用
1.将成员变量用private修饰 2.提供对应的getxx()和setxx()方法 public class Student { private String name; private int a ...
- [好好学习]在VMware中安装Oracle Enterprise Linux (v5.7) - (2/5)
- [译]理解 SwiftUI 里的属性装饰器@State, @Binding, @ObservedObject, @EnvironmentObject
原文地址:https://mecid.github.io/2019/06/12/understanding-property-wrappers-in-swiftui/ @States 通过使用 @St ...
- web页面和本地数据对比问题
缘起 最近工作上出现了遇到了几个类似的问题:页面上有值,excel里有值,需要比较二者是否一致.小麻烦有:1.对于页面上的值,有时是页面表格里的一列或几列,无法直接勾选并复制出来.即便复制出来,也很不 ...
- pg_ctl - 启动,停止和重启 PostgreSQL 服务器
SYNOPSIS pg_ctl start [ -w ] [ -s ] [ -D datadir] [ -l filename] [ -o options] [ -p path] pg_ctl sto ...
- 一、ffmpeg理论
一.ffmpeg三件套 ffprobe看文件属性 ffmpeg 编转码 ffplay 播放器 C:\Users\Bruce\Desktop\Temp\ffmpeg\ffmpeg\ToolPack\ff ...