PHP fopen from windows to external unix server

I have a trouble with fopen(), the function returns “failed to open stream: No such file or directory” when i am trying to write file which is on unix server.
My PHP application is running on Windows.

This is the code where I am using the fopen function :

$path = "/212.120.15.80/tmp/NMJ.pdf"; //Path to unix server
$url = $_FILES [$fileElementName] ['tmp_name'];


     $newfname = $path;

     $file = fopen ( $url, "rb" );
     if ($file) {
        $newf = fopen ( $newfname, "wb" );
        $fopen = $newf;

        if ($newf) {
            while ( ! feof ( $file ) ) {
                fwrite ( $newf, fread ( $file, 1024 * 8 ), 1024 * 8 );
            }
        }
     }
     if ($fopen === false) {
        $return_fopen = 'Fichier non téléchargé';
     } else {
        $return_fopen = 'Le fichier a été déposé sur le serveur';
     }

     if ($file) {
        fclose ( $file );
     }
     if ($newf) {
        fclose ( $newf );
     }

I have write/read access on the tmp directory.

This code works when I am writing a file on a windows server with this path : “\\Example/share”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s