Solved

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

Posted on 2006-11-21
6
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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