Solved

Best Way for Upload Files to WebServer.. How Create a CGI in delphi?

Posted on 2006-11-21
6
266 Views
Last Modified: 2010-04-05
wich is the best way for upload a text file to webserver?

i know how download:

  if paramstr(1)='1' then
    assignfile(f,ExtractFilePath(Application.ExeName)+'Tablei.dbh')
  else
  begin
    IdHTTP1.HandleRedirects := True;
    Stream := TMemoryStream.Create;
    IdHTTP1.Get('http://www.grupolanortenita.com/miguel/Tablai.dbh', Stream);
    Stream.Position := 0;
    Stream.SaveToFile(GetWindowsTempDirectory+'_Xi.tmp');
    Stream.free;
    assignfile(f,GetWindowsTempDirectory+'_Xi.tmp')
  end;
  reset(f);

i know that exist 2 ways:
via FTP and/or creating a CGI, how create a CGI?

thanks

0
Comment
Question by:jamiguel
6 Comments
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 25 total points
ID: 17990478
ftp is easier. If you have Indy, then take a lok at TIdFTP
It's pretty easy to use
CGI is server side, so you'd have to get the server to allow your cgi module (which is a risky thing for them)
0
 

Assisted Solution

by:huiyue
huiyue earned 25 total points
ID: 17992233
you can create a service with idTCPServer component in delphi.
and install the service to the server.
At the client side, the client software use idTCPClient to connect to the server.
Here is the simple code about send and receive data.
//simple start
//send
//before this you should initialize the server host and port of the idtcpclient object.
with TCPClient do
  begin
      if not Connected then
      begin
        Connect(1000);
      end;
      fileStream := TFileStream.Create(strFileName,fmShareDenyNone);
      OpenWriteBuffer();
      WriteStream(fileStream, true, true,fileStream.Size);
      CloseWriteBuffer;
      DisconnectSocket;
      Result := True;
      fileStream.Free;
  en;
//receive (in TCPServerExecute method)
    with AThread.Connection do
    begin
       fs := TFileStream.Create(strFilePath,fmCreate);
       ReadStream(fs, -1, False);
       fs.Free;
    end;
//simple End
and you'd better to make some encrypted command to make sure that the data is the right client send.
Hope this can make some help for you.
0
 

Author Comment

by:jamiguel
ID: 17992463
But the cgi? how start program the cgi?

thanks
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17993642
Depending on what version of Delph you have, you choose "File-New" - and then in the wizard that appears you can choose 2 kinds of CGI application
If you have a personal edition of Delphi (as opposed to Client/server or enterprise) then this option may not be available
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21135803
Forced accept.

Computer101
EE Admin
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now