Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-21
6
Medium Priority
?
273 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 100 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 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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