PHP: CURL library: Getting status of curl_exec -


i using curl in php write function remote xml file local folder. works fine have question:

  $filein = curl_init("http://some-remote-host.com/file.xml);   $fileout = fopen('mylocal.xml", "w");    curl_setopt($filein, curlopt_file, $fileout);   curl_setopt($filein, curlopt_header, 0);    $iscopied = curl_exec($filein);   curl_close($filein);   fclose($fileout);    if(!$iscopied)      return false;   else      //do else 

based on documentation read, $iscopied supposed false when remote file not exist, , there shouldn't mylocal.xml if(!$iscopied) doesn't seem tobe working. , content of mylocal.xml

<!doctype html public "-//ietf//dtd html 2.0//en"> <html><head> <title>404 not found</title> </head><body> <h1>not found</h1> <p>the requested url something.xml not found on server.</p> <hr> <address>apache server @ somehost.com port 443</address> </body></html> 

my question is: how boolean variable telling me when succeeded , when did not. (means when remote file doesn not exist).

thank you.

you can use

curl_getinfo($filein, curlinfo_http_code);  

to see http code returned (you're looking 200).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -