cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: problems downloading files with differents ports

From: Marcos Santos Junior <msjunior_at_gmail.com>
Date: Wed, 28 Jan 2009 13:58:42 +0000

the structure below, worked fine - with no errors nor notices neither
warnings. tested 3 times
my enviroment:
PHP 5.2.6
cURL: 7.16.0

all the best

Marcos

<pre>
<?php

 error_reporting(E_ALL);
 set_time_limit(0);

function get_file1($file, $local_path, $newfilename)
{
    $local_file = $local_path.$newfilename ;

    $ch = curl_init( $file );

    curl_setopt($ch, CURLOPT_HEADER, false );
    curl_setopt($ch, CURLOPT_VERBOSE, true );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($ch, CURLOPT_FAILONERROR, true );

    $content = curl_exec( $ch );
    $header = curl_getinfo( $ch );
    $header['errno'] = curl_errno( $ch );
    $header['errmsg'] = curl_error( $ch );
    curl_close( $ch );

    @file_put_contents($local_path.$newfilename , $content , LOCK_EX );
 if( file_exists($local_path.$newfilename) )
   return(true);
 else
   return( $header );

}
 $local = "C:\\xxxxxxx\\xxxxxxx\\xxxx\\xxxxx\\mydir\\" ;
 $new_name = date('Y-m-d_H-M-s').".mp3" ;
 $file = "
http://213.97.223.180:8003/AUDIO_A_LA_CARTA/28-01-2009_09-00-02_DIRECTO_MARCA_CON_JUAN_MANUEL_GOZALO.MP3"
;

 $arr = get_file1( $file , $local , $new_name);
 // if an array is returned , means the process failed
 if( is_array($arr) ){
   print_r( $arr , true );
 }
 else{
  print("Sucess. \n");
 }
?>
</pre>

2009/1/28 Charoite Lee <charoitelee_at_rhoware.com>

> Hi Jordi,
>
> How about if you are not using cURL but fsockopen? Please visit
> http://www.php.net/fsockopen for reference. Hope this help and good luck
> to you.
>
> Regards,
> Charoite
>
> Jordi Agusti Fonoll wrote:
>
> Hi Daniel,
>
> I think this is not the problem, because I have just this problem when
> the URL has a port. For example this other URL:http://ficheros.orm.es:3025/descarga/peldano/20070706UP.mp3
>
> give me the same problem:
>
> About to connect() to ficheros.orm.es port 3025
> * Trying 80.73.144.119... * Connection refused
> * couldn't connect to host
> * Closing connection #0
> <br>Error is : couldn't connect to host
>
> This files are public and everybody can download it.
>
> Regards.
>
> -----Mensaje original-----
> De: curl-and-php-bounces_at_cool.haxx.se
> [mailto:curl-and-php-bounces_at_cool.haxx.se <curl-and-php-bounces_at_cool.haxx.se>] En nombre de Daniel Stenberg
> Enviado el: 2009-01-28 13:12
> Para: curl with PHP
> Asunto: RE: problems downloading files with differents ports
>
> On Wed, 28 Jan 2009, Jordi Agusti Fonoll wrote:
>
>
>
> About to connect() to 213.97.223.180 port 8003
>
> * Trying 213.97.223.180... * Connection refused
>
>
> The machine using IP address 213.97.223.180 does not accept connections
> on
> port 8003 from the host you're running this on.
>
> There's nothing you can do about it. Ask the admins of the server you
> run this
> program on and of the server you're trying to connect to, to get further
>
> details on why this happens.
>
> This is not a bug in curl (or PHP) nor in your program.
>
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-01-28