CodeIgniter Forums
use php file that's not in webroot from javascript / ajax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: use php file that's not in webroot from javascript / ajax (/showthread.php?tid=53823)



use php file that's not in webroot from javascript / ajax - El Forum - 08-10-2012

[eluser]Unknown[/eluser]
I'm using an ajax function that requires a php file and I'd like to put the php file out of the webroot for security reasons. How can I refer to this php file in this function when this php file is outside the webroot?

Code:
$.ajax({
          
              type: "POST",
              url: "http://localhost/clb/scripts/secondary.php",
              async: false,
              data: {id : id , secondary_id : secondary_id },
              success: function(msg)
              {
                
            }               });



use php file that's not in webroot from javascript / ajax - El Forum - 08-10-2012

[eluser]PhilTem[/eluser]
It's simple: You can't.

Though this answer sounds harsh, but without any further fixes it's not possible. Everything that you want to access via an URL/URI needs to be at the same level or below webroot level. The only possibility would be creating an alias (htaccess or apache2-conf) that points to another directory. However, files will then be directly accessible via the alias.

Therefore: For AJAX every file needs to be accessible via an URL/URI Wink


use php file that's not in webroot from javascript / ajax - El Forum - 08-11-2012

[eluser]vitoco[/eluser]
what did you meant with ?

Code:
I’d like to put the php file out of the webroot for security reasons