Welcome Guest, Not a member yet? Register   Sign In
Where should I put this file?
#1

[eluser]whygod[/eluser]
Hi guys,

In my view file, I have this jQuery codes,
Code:
$.get('getprogress.php', { uid: id, t: time }, function (data) {
    //more codes here...
}

So where should I put getprogress.php in what folder?

I hope someone will help me.

Thanks in advance.
#2

[eluser]Pert[/eluser]
Assuming getprogress.php is a controller, it goes to application/controllers/ folder, but your URL will be just getprogress without .php
#3

[eluser]whygod[/eluser]
@Pert
It's not a controller, It's just an ordinary PHP.
And below are the codes of it.
Code:
<?php
if (isset($_GET['uid'])) {
  
  // Fetch the upload progress data
  $status = uploadprogress_get_info($_GET['uid']);
  
  if ($status) {
  
   // Calculate the current percentage
   echo round($status['bytes_uploaded']/$status['bytes_total']*100);
  
  }
  else {
  
   // If there is no data, assume it's done
   echo 100;
  
  }
}
?>

So where should I put an ordinary PHP codes?
#4

[eluser]whygod[/eluser]
Okay lets assume I'll put those codes in the controller as a method.
Is this the right jQuery codes to call the controller method from a view file?
[code]
$.get("<?php echo base_url('controller_name/getprogress.php') ?>", { uid: id, t: time }, function (data) {
//more codes here...
}
[code/]

Hope someone will give shed.
Thanks in advance.
#5

[eluser]Pert[/eluser]
If you must use just PHP you can put it anywhere you want, project root next to index.php or you can create your own subfolder.

I would suggest you try to convert it to a controller if at all feasible, it will give you all the nice CodeIgniter features.

As far as I can see this file doesn't really do that much so I can see the logic in not asking it to load CodeIgniter etc.

Are you using URL rewrite?
#6

[eluser]boony[/eluser]
Woof woof,

Just put the code in a method in your controller and then pass it to the $.get('controller/getprogress')...
no need to echo the base_url and drop the .php bit..

Boony




Theme © iAndrew 2016 - Forum software by © MyBB