cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

a download

From: Colleen R. Dick <platypus_at_proaxis.com>
Date: Thu, 06 Dec 2007 16:47:51 -0800

I have managed to log into a site and make it do a query and have my
custom data appear on a dynamic web page (if I choose to print out the
results of curl_exec.)
There is a BUTTON on that page that allows you to download a spreadsheet
of that data. You can't just fetch the file with wget or curl because
I'm sure it doesn't live anywhere under document root so it wouldn't
have a URL. you have to submit the form to ask the server for it and it
downloads it as some sort of attachment with a dialog when you do it
manually. Obviously I want to set it up so it just falls into some
file handle. I checked what the button does, it just calls a
javascript to set up some other post variables before submitting the
form.

Here is the submit button:

<input class="button" type="button" value="Export All Data"
onclick="exportFile(); return(false);

Here is the javascript exportFile:

function exportFile()
        {
            document.RptForm.pageno.value = 1;
            document.RptForm.expflag.value = 1;
            document.RptForm.rptaction.value = "qryordertime";
            
                document.RptForm.pagefile.value = "temp1196982492309.1040408.1";
            
            exptype = document.RptForm.exptype.options[document.RptForm.exptype.selectedIndex].value;
            if (exptype=="csv") document.RptForm.expfile.value="exp_ordercsv.xsl";
            else if(exptype=="xml") {
                document.RptForm.target = "_blank";
                document.RptForm.expfile.value="exp_orderxml.xsl";
            }
            document.RptForm.submit();
            document.RptForm.target = "_self";
        }

So what I did was hard code all the post variables like the javascript does them
and submits the form.
It doesn't throw any errors, I don't think. I made it print out curl_getinfo
Array
(
    [url] => https://www.linkpointcentral.com/lpc/servlet/LPCReport
    [content_type] => text/html; charset=ISO-2259-1
    [http_code] => 200
    [header_size] => 153
    [request_size] => 665
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 2.981608
    [namelookup_time] => 0.000101
    [connect_time] => 0.113942
    [pretransfer_time] => 0.529531
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 2.981528
    [redirect_time] => 0
)

It names the document rpt*******.csv but I would like it to download into a file name of my choice.
To that end I have set up and opened a filehandle but it always ends up of size zero, which makes sense if
I don't know how to tell CURL to use it. Where is the document going if anywhere?
It is not in tmp or in my web tree. I'm sorry if I am stupid but I have really looked very hard for the answer.
All I see is little examples to use Curl to download a file where it has a URL. I know how to do that.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-12-07