Welcome Guest, Not a member yet? Register   Sign In
use php file that's not in webroot from javascript / ajax
#1

[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)
              {
                
            }               });
#2

[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
#3

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

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




Theme © iAndrew 2016 - Forum software by © MyBB