send image and audio to server through APP

		header('content-type:text/html;charset=utf8');

		$ch = curl_init();

		//加@符号curl就会把它当成是文件上传处理
		$data = array(
			'img'=>'@'. dirname(__FILE__).'/test/1.jpg',
			/*'audio'=>'@'. dirname(__FILE__).'/test/1.amr',*/
			'room'=>'test',
			'user'=>'test'
		);
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
		curl_setopt($ch,CURLOPT_POST,true);
		curl_setopt($ch,CURLOPT_VERBOSE, true);
		//curl_setopt($ch,CURLOPT_STDERR,  'php://output');
		curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
		if(curl_exec($ch) === false){
			echo 'Curl error: ' . curl_error($ch);
		}else{
		    $result = curl_exec($ch);
			var_dump($result);
		}
		curl_close($ch);
		echo $result;

 

你可能感兴趣的:(server)