Alon Adler
Alon Adler

Reputation: 4024

Cant find PHP file with AJAX request

I have a PHP file that is located in: /epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php

its permissions are rwxrwxrwx (777) and owners are epcvt : users

I want to call the runVT.php file by an AJAX request initiated from this file: /var/www/html/evtgen/evt_run.php

I've tried to call it by this Javascript:

var xmlhttp;
if (window.XMLHttpRequest) 
{
    xmlhttp=new XMLHttpRequest();
}
else
{
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.open("GET","/epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php" ,true);
xmlhttp.send();

}

But I'm always getting a file not found response:

The requested URL /epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php was not found on this server.

I've also tried

xmlhttp.open("GET","../../../../epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php" ,true);

and

xmlhttp.open("GET","epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php" ,true);

But that didn't work either.

To check if I'm missing something on the folder i went to the /var/www/html/evtgen/ folder in the Unix and checked both:

vi /epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php
vi ../../../../epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php

And they both worked (I got the script text). What am I missing ?

Upvotes: 0

Views: 601

Answers (1)

Dave Chen
Dave Chen

Reputation: 10975

Make a file in the document root (/var/www/html/), call it whatever you want.

Inside this file, have it call your file /epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php.

Example:

<?php

require_once '/epcusers/toolsamc/users/epcvt/VT/CTM/CTM80/Billing/bin/runVT.php';

Anything that isn't inside the document root, can't be accessed by the client-side, unless you have a PHP file linking it, (or apache rewrite, but that's another story).

Upvotes: 1

Related Questions