10

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
jim
  • 103
  • 1
  • 1
  • 4

4 Answers4

13

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

Silver Light
  • 44,202
  • 36
  • 123
  • 164
10

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';
bcosca
  • 17,371
  • 5
  • 40
  • 51
  • Rockjock, I am currently using forward slashes but the file still won't load. The only way I can get the file to load os by putting "file:// in front of the "C:\" – jim Feb 25 '10 at 14:22
  • right, but the debugging right now is on a winbox so we need to isolate the problem – bcosca Feb 25 '10 at 14:41
1

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

'C:\Program Files (x86)\work\site\js\rowlock.js'
Andy
  • 49,085
  • 60
  • 166
  • 233
1

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

streetparade
  • 32,000
  • 37
  • 101
  • 123
  • I was hoping to use the absolute path so that if I ever wanted to change the directory structure, it wouldn't be that big of a deal. – jim Feb 25 '10 at 14:25