I've been struggling to download a file from a network file share using
cURL, or whatever else will work.   All I want to do is get the contents of
a text file.  But when I run the code below I get this error "Error: 37 -
Couldn't open file \\server\share\test.txt".  I'm running my website on a
linux box, but the server is on a Windows file server.  I've verified that
the file share works when I use Windows Explorer and that the server can get
the file via the command line using smbclient.  Any help would be
appreciated.

<?PHP
$file = "file:\\\\server\\share\\test.txt";

    echo "<p>Getting $file</p>\n";

    // create a new cURL resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, $file);
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");
    curl_setopt($ch, CURLOPT_HEADER, false);

    // grab file and pass it to the browser
    echo "<p>File: " . curl_exec($ch) ."</p>\n";
    echo "<p>Error: " . curl_errno($ch) . " - " . curl_error($ch) .
"</p>\n";
?>

Thanks,
Robbert

Reply via email to