Re: Bad File Mode?

From: Date: Thu, 28 Nov 2002 12:42:11 +0000
Subject: Re: Bad File Mode?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-126400@lists.php.net to get a copy of this message
You can stat (get filesize, modification time, permissions) only local files - download it first and then get its filesize if you need it. Steve Keller wrote:
I'm still trying to get a file posted to another server, but I seem to have run across an odd snag, and I was hoping someone can point out where I've gone wrong. Here's the code: <?
        $data = "mtype=XMLDOC&outfile=true";
        $dataFile = "http://www.healthtvchannel.org/courses/pay/data/test.xml";
        $fileSize = filesize($dataFile);
        $fp = fopen($dataFile, "rb");
        $strFile = fread($fp, $fileSize);
        fclose($fp);
        $osbURL="https://partners.netledger.com/SmbXml";
        $ch = curl_init();
        $res = curl_setopt($ch, CURLOPT_POST, 1);
        echo "Set Post: ".$res;
        $res = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        echo "<br />Set Follow: ".$res;
        $res = curl_setopt($ch, CURLOPT_VERBOSE, 1);
        echo "<br />Set Verbose: ".$res;
        $res = curl_setopt($ch, CURLOPT_URL, $osbURL);
        echo "<br />Set URL: ".$res;
        $res = curl_setopt($ch, CURLOPT_POSTFIELDS, $data."&mediafile=".$strFile);
        echo "<br />Set Postfields: ".$res;
        $res = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        echo "<br />Set ReturnTransfer: ".$res;
        $result = curl_exec($ch);
        curl_close($ch);
        echo $result;
?> What I'm getting is Warning: stat failed for http://www.healthtvchannel.org/courses/pay/data/test.xml (errno=2 - No such file or directory) in /usr/local/www/vhosts/healthtvchannel.org/htdocs/courses/pay/posttest.php on line 20 I'm positive the file exists, and if I cut and paste the URL from the error to a browser window, I can see the file. What am I doing wrong? -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org


« previous php.general (#126400) next »