CodeIgniter Forums
facing Url problem with codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: facing Url problem with codeigniter (/thread-23319.html)



facing Url problem with codeigniter - El Forum - 10-06-2009

[eluser]muzahir[/eluser]
Hi,

In codeigniter, i have to access the controller by giving its path e.g "http://www.test.com/system/application/controllers/uploader.php" instead of "http://www.test.com/index.php/uploader" (as we use in CI).

But, when i access it by giving its path then i does not load the controller(parent class which i have extended) and i got the error so i can't get the $this (CI) object also for further use.

Please help me in finding the solution of my problem. is there any way to tackle that kind of problem.. i will be very pleased and thankful for your replies


facing Url problem with codeigniter - El Forum - 10-07-2009

[eluser]pistolPete[/eluser]
Why do you access the controller directly using http://www.test.com/system/application/controllers/uploader.php ?
What errors do you get?
Post your controller code.


facing Url problem with codeigniter - El Forum - 10-07-2009

[eluser]muzahir[/eluser]
I am accessing it directly because i am using aurigma (an image uploader) which has a property named as setAction where we have to provide the url.

$iu->setAction("url here on which we can receive response");

when i pass the controller path as "http://www.test.com/index.php/uploader" to setAction method, it does not accept it as it needs direct path as "http://www.test.com/system/application/controllers/uploader.php". i am dependent on aurigma and can't change his style of accepting action url which is totally different as of CI.
thats why need to pass direct path and as a result CI does'nt load any pre controllers and doesn't extend the parent classes

After directly accessing the file i got the error "cannot find class named as MY_Controller.php"

My Controller Code is here:

class Uploader extends MY_Controller{


public function Uploader()
{
parent::__construct();
$this->load->helpers('url');
$this->load->helpers('form');
$this->_user="";
}
public function index()
{
$File = "YourFile.txt";
$Handle = fopen($File, 'w');
$html .='get IS '.$_GET['user'].' \n';

foreach($_GET as $key=>$val)
{
$html .=$key.'==>'.$val."\n";
}
$html .='pOST count is '.$_POST['FileCount'].' \n';

foreach($_POST as $key=>$val)
{
$html .=$key.'==>'.$val."\n";
}
$Data = $html;
fwrite($Handle, $Data);
fclose($Handle);
}

}// end class

Looking for your help. Thanks!
?>


facing Url problem with codeigniter - El Forum - 10-07-2009

[eluser]pistolPete[/eluser]
Please use [ code ] tags.

Why wouldn't the image upload accept http://www.test.com/index.php/uploader ?
Can you access this url if you enter it in your browser?


facing Url problem with codeigniter - El Forum - 10-07-2009

[eluser]muzahir[/eluser]
Code:
<?php
class Uploader extends MY_Controller{


public function Uploader()
{
  parent::__construct();
  $this->load->helpers(‘url’);
  $this->load->helpers(‘form’);
  $this->_user=”“;
}
public function index()
{
  $File = “YourFile.txt”;
  $Handle = fopen($File, ‘w’);
  $html .=‘get IS ‘.$_GET[‘user’].’ \n’;

  foreach($_GET as $key=>$val)
  {
      $html .=$key.’==>’.$val.”\n”;
  }
  $html .=‘pOST count is ‘.$_POST[‘FileCount’].’ \n’;

  foreach($_POST as $key=>$val)
  {
      $html .=$key.’==>’.$val.”\n”;
  }
  $Data = $html;
  fwrite($Handle, $Data);
  fclose($Handle);
}

}// end class

Looking for your help. Thanks!
?>

CI type url is: "http://www.test.com/index.php/Uploader"
so when i acceess this url directly from browser then their is no problem but when i pass it as an action of aurigma (image uploader) it doesn't recognize it.
Thats why, i want a solution for that as image uploader has a jar file and i cant recognize its functionality, how he handle action request.


facing Url problem with codeigniter - El Forum - 10-07-2009

[eluser]pistolPete[/eluser]
I suggest using a network sniffer (e.g. wireshark) to monitor the communication between the uploader and the CI controller; have a look at errors (e.g. 404), sessions, cookies, etc.