Monday, 15 February 2010

php - Directory path calls, strange behaviour -



php - Directory path calls, strange behaviour -

i have ajax request i'm trying phone call specific file located at:

root/admin/functions/upload/filename.php

and page making request located at:

root/admin/customers/123

which modified through htaccess from

root/admin/customer.php?id=123

i have tried every combination of paths think of unusual behaviours illustration when use

../functions/upload/filename.php

it looks file in

root/functions/uploads/filename.php

and when use

functions/upload/filename.php

it looks file in

root/admin/customers/functions/uploads/filename.php

so tried

../admin/functions/upload/filename.php

and looks in

root/admin/admin/functions/upload/filename.php

i'm pulling hair out here, has got ideas might be?

any help appreciated.

thanks, james.

since browser knows nil server-side paths, , has path see in address bar, e.g.

http://example.com/root/admin/customers/123

then if ajax code looks like

$.ajax('functions/foo/bar.php');

then ajax phone call requesting

http://example.com/root/admin/customers/123/functions/foo/bar.php

similarly, adding ../ strips off levels of source page's address:

$.ajax('../../functions/foo/bar.php');

results in

http://example.com/root/admin/customers/123/../../functions/foo/bar.php ^-a-^ ^-------b------^ http://example.com/root/admin/functions/foo.bar.php

you want

$.ajax('/root/functions/foo/bar.php');

with leading /, browser ignores of subdirectory stuff in url , uses entire path ajax phone call entirety of path.

http://example.com/ + /root/functions/foo.bar.php

php jquery .htaccess path

No comments:

Post a Comment