logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: how can i handle with "<url> malformed".: msg#00017

Subject: Re: how can i handle with "<url> malformed".
Your problem might be with the way you are posting the data.

Back in March someone else was having a similar problem, and my solution was:

   I've hacked an example that I found somewhere to do this:
   function varEncode($varArray)
   {
      $args = array();
      foreach($varArray as $key => $value){
          array_push($args,$key.'='.urlencode($value));
      }
      return implode('&',$args);
   }

   To encode it:
   $urlstring =varEncode(array('id'=>'888','request'=>$xmlcontent));

   Then you can post the $urlstring
   curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);

In your case try adding the following after your posts array:

$urlstring = varEncode($posts);

And change the line:

curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);

to:
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);

--JJ--

Tomohiko Tani wrote:

hello,
I got an error code "<url> malformed", when I exec file upload script like this.

Is it impossible to post not only file data but other parameters at
the same time?


<?php
$url = "https://www.example.co.jp/test.cgi";;
$pass = "aaaaaaa:bbbbbb";
$input_name ="up_file";
$posts = array(
        "mode" => $mode,
        $input_name => "@" . $file_name,
);

curl_fileupload($url, $pass, $posts);

function curl_fileupload($uri, $passwd, $posts){
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL,$uri);
        curl_setopt($ch, CURLOPT_HTTPAUTH,"CURLAUTH_BASIC");
        curl_setopt($ch, CURLOPT_USERPWD,$passwd);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);

        $result_upload = curl_exec($ch);
        
        if (curl_errno($ch)){
                print curl_error($ch);
        }else{
                print "upload ok.\n";
                curl_close($ch);
        }
}
?>






Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>