Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:18:07+00:00 2026-06-09T13:18:07+00:00

I need to transfer a file from my Unix machine to a Windows machine.

  • 0

I need to transfer a file from my Unix machine to a Windows machine. Problem is i can transfer a file already created on my machine via ftp from unix to any machine. also i can open webdav connection create new file and save it there.

What i am unable to do is to write my code to upload my file fro my local location using webdav.

i tried using pear client but due to lack of documentation, i am still not able to achieve the task .

Here is my attempt:

include("/usr/share/pear/HTTP/WebDAV/Client.php");
global $filename, $logger;
    try {
     /*   $client = new HTTP_WebDAV_Client();
        $user="username";
        $pass = "pwd";
        $dir = "webdavs://".$user.":".$pass."@hostname/";
        var_dump($client->stream_open($dir."test4.txt","w",null,$path));
        $client->stream_write("HELLO WORLD! , I am great ");
        $client->stream_close();
        $client->dir_opendir($dir,array());
        var_dump($client->dirfiles);


        $req =new HTTP_Request($dir);
        $req->setBasicAuth($user, $pass);
        $req->setMethod(HTTP_REQUEST_METHOD_POST);

        $result = $req->addFile('file_upload_field', $filename);
        if (PEAR::isError($result)) {
            echo $result->getMessage();
        } else {

            $response = $req->sendRequest();

            if (PEAR::isError($response)) {
                echo $response->getMessage();
            } else {
                echo $req->getResponseBody();
            }
        }*/

        $ftp_server = "hostname-ftp";
        //$ftp_server = "hostname-webdav";
        $connection = ftp_connect($ftp_server);
        ftp_login($connection, 'user', 'pwd);
        ftp_put($connection, $filename, $filename, FTP_BINARY);
        unlink($filename);
    } catch(Exception $e){
        $message = "There was a problem while uploading" . $filename;
        $logger->error($message);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:18:08+00:00Added an answer on June 9, 2026 at 1:18 pm

    It was a togh call, but i figured it out. I am adding my code snippet so it may be helpful for someone. Instead of uploading the file, i converted that file into data stream and then copied that data stream to my call that writes stream on webdav server.

    try {
            $filecsv = file_get_contents($filename);
            $client = new HTTP_WebDAV_Client_Stream();
            $user="user";
            $pass = "pass";
            $dir = "webdavs://".$user.":".$pass."@hostname/";
    
            $client->stream_open($dir."db_user_exports.csv","w",null,$path);
            $client->stream_write($filecsv);
            $client->stream_close();
            unlink($filename);
    
        } catch(Exception $e){
            $message = "There was a problem while uploading" . $filename;
            $logger->error($message);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transfer all data from a OLEDB source to XML file and
I need to transfer a log file to a remote host using sftp from
I need to automatically transfer an xml file from server A over internet to
I need to transfer data daily from SQL Server (2008) to SQL Server (2005).
I need to write a simple file transfer protocol in C++ to upload or
I need the package having below features: needs client based secure file transfer machanism
I'm making a file transfer application between (client-server) and have the tools I need
I need to transfer files from an iPad in Airplane Mode (such that neither
I am trying to make a bash script that will transfer a file from
I need a format to transfer data from program A to program B, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.