Jump to content

Recommended Posts

Hey everyone,

 

Here is a bit of a weird one. I set up ownCloud using a PAAS service and it is running well. However, when I try to use curl from PHP, I keep getting an error that says "Failed to connect to THEURL port 80: No route to host"

This is weird for two reasons.

1. I also tried uploading it from my computer's terminal, using curl, and that

2. Until about a day ago, I had my own cloud on a shared host, and the PHP code worked just fine.

 

Here is the PHP code I used:

    function uploadToOwncloud($args = array()){
        $uploadPath     = $args['uploadPath'];
        $product_data   = fopen('php://memory', 'r+');
        fputs($product_data, $args['product_data']);
        rewind($product_data);

        $user           = $args['user'];
        $pass           = $args['password'];
        $url            = "MYOWNCLOUDURL.COM/remote.php/webdav" .urlencode($uploadPath);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
        curl_setopt($ch, CURLOPT_PUT, 1);
        
        curl_setopt($ch, CURLOPT_INFILE, $product_data);
        curl_setopt($ch, CURLOPT_INFILESIZE, fstat($product_data)['size']);
        
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
        
        $curl_response_res = curl_exec ($ch);
        var_export(curl_error($ch));
        return;
    }

Here is the terminal command I used:

curl -u "user:password" -T test.txt "http://myowncloudurl.com:80/remote.php/webdav/text.txt"

I tried adding my domains to the whitelist, and turning off the fire wall

Thanks

Link to comment
https://forums.phpfreaks.com/topic/327789-no-route-to-host-with-owncloud/
Share on other sites

 

You should clarify:

  • You have not changed client php code at all?   
  • When you ran curl from the cli on this same computer, did that work?

Have you rebooted, the workstation you are using to connect to your owncloud?  If it involved a DNS change on your part, if the DNS information was cached and stale, it's possible that your workstation was still resolving to the old host, and an IP that perhaps no longer works.

It's also possible that this PaaS platform doesn't have port 80 open.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.