开发者

Help with windows path - PHP

I have this path and it is correct however, the browser will not include the source file unless I put "file:///" in front of it. I'm still developing and开发者_运维技巧 this will ultimately be on a Linux machine but in the mean time, I'd like to see my work as well as be able to troubleshoot it. Is there a solution for this?

This fails:

C:\Program Files (x86)\work\site\js\rowlock.js

This does not fail:

file:///C:\Program Files (x86)\work\site\js\rowlock.js


Try using variable $_SERVER['DOCUMENT_ROOT'] to make your script independent. For example:

include($_SERVER['DOCUMENT_ROOT'].'/js/rowlock.js');

Works fine on any system


just use front slashes everywhere if you'll be moving this to a linux box anyway. php for windows can understand it.

$file='c:/Program Files (x86)/work/site/js/rowlock.js';


Put quotes around your path. You have spaces, so it is not read correctly.

'C:\Program Files (x86)\work\site\js\rowlock.js'


Where is Your root folder?

If its C:\Program Files (x86)\work\site\

Then simple access your file like this

js/rowlock.js

This assuming that js is in the Root folder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜