Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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