write mismatch

Posted on 2006-04-20
Last Modified: 2013-12-25
apache runs on host A  and all the cgi code is on host A
(cgi code uses <input type=file> to get the file

when i run executethe url from host B, i give th epath of the file c:\test\test.txt of host B.
the cgi creates a file out.txt, but cgi writes this file on the server A and not on my host B from where I am running.
Question by:perlperl
    LVL 48

    Accepted Solution

    Looks like you are a little unclear on CGI, HTTP and web server technologies.

    <input type=file>

    is not CGI code, it is HTML.

    If your CGI program/script runs on host A, the only way it can write a file on Host B is by using what ever appropriate protocol you have setup between the two hosts.  This maybe ssh, ftp, NFS, SMB, HTTP or any number of other protocols.

    Author Comment

    yes, i am new to cgi world....
    Here is what I am looking.
    I have host A, where Apache runs as web server......I have my website (all cgi scripts on host A)

    now if the user hits the url  , the html  has browse button which asks user the filename.
    test.html then gets redirected to   this creates a file called out.txt, problem it is saving the file in C: of host A.
    I wwant to this file on the customers local desktop C:
    What settings I need to do?

    Author Comment

    how can my cgi running on Host A can save a copy of file i create on customers local desktop.......

    Author Comment

    also, in test.html, user specifies the file c:\create.txt, but my cgi is looking for this file on host A C:\create.txt instead of using customers C:\create.txt

    I am a bit confused
    LVL 51

    Expert Comment

    > I wwant to this file on the customers local desktop C:
    your process.cgi has to return the file with a HTTP-header like
      Content-Type: data/unknow
    which forces the browser to open the download dialog

    Assuming your process.cgi is perl, then that part looks like:

      use CGI;
      my $q=new CGI;
      $text="here is your text from the file out.txt";
      print $q->header(-type=>"data");
      ptint $text;
      exit( 0 );

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
    I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now