Help on a Windows path - PHP

I have this path and this is correct, however the browser will not include the source file unless I put "file: ///" in front of it. I am still developing, and it will ultimately be on a Linux machine, but in the meantime, I would like to see my work and also eliminate it. Is there any solution for this?

This fails:

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

This does not work:

 file:///C:\Program Files (x86)\work\site\js\rowlock.js 
+6
php
source share
4 answers

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

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

Works great on any system

+7
source share

just use front slashes everywhere if you move this to linux anyway. php for windows can figure it out.

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

Place quotation marks around your path. You have spaces, so they are not read correctly.

 'C:\Program Files (x86)\work\site\js\rowlock.js' 
+1
source share

Where is your root folder located?

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

Then skip access to your file like this

Js / rowlock.js

Assuming js is in the root folder

+1
source share

All Articles