Solved

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

Posted on 2006-11-21
6
272 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

617 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