为什么上传不了文件,就是17.6.1.99这个服务器在11这个文件夹下没有123.doc的文件,而浏览器输入这个地址'http://17.6.1.99:8888/11/1.asp'也是正常的,程序也不报错!
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,Idhttp, URLMon, IdMultipartFormData, StdCtrls;
 const UpUrl = 'http://17.6.1.99:8888/11/1.asp';
 const UpFileName = 'd:\123.doc';
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
     MutPartForm: TIdMultiPartFormDataStream;
     response: string;
     FHttp: Tidhttp;
beginFHttp := Tidhttp.Create(nil);
     FHttp.HandleRedirects := true;
     FHttp.AllowCookies := true;    MutPartForm := TIdMultiPartFormDataStream.Create;
     MutPartForm.AddFormField('act', 'upload');
     MutPartForm.AddFormField('upcount', '1');
     MutPartForm.AddFormField('filepath', 'data');
     MutPartForm.AddFormField('file1', 'filename='''+UpFileName+'''');
     MutPartForm.AddFormField('Submit', 'Submit');
     MutPartForm.AddFile('file1', UpFileName, 'text/plain');
     try
         response := FHttp.Post(UpUrl, MutPartForm);
     Messagebox(0, PAnsiChar(response), 'ca', MB_OK);
    finally
         MutPartForm.Free;
         FHttp.Free;
     end;end;end.

解决方案 »

  1.   

    web服务器默认asp文件是不允许上传的,所以需要对web服务器进行相关配置。
      

  2.   


    对,好像一般都是ftp上传的。
      

  3.   

    你是什么web服务器?
      

  4.   

    先用asp页面 测试看能不能上传,
    同时开httpwatch 监控 asp页面
      

  5.   

    1.asp是结束文件上传的web应用?
    它已经被配置为可执行了吗?子目录的权限也是web进程的账号可以读写的吗?
      

  6.   

    改一下上传文件类型试试。。
    MutPartForm.AddFile('file1', UpFileName, 'multipart/form-data');
    FHttp.Request.ContentType := MutPartForm.RequestContentType;