PHP 'include' question

I have a script located at localhost/uploader/ In this directory there are directories for the script’s CSS and JS and IMAGES, etc. If I run http://localhost/uploader/ everything works perfectly.

This script is part of a larger project. When I try to access this script using “include “…/uploader/index.php”;” it finds the script but not the CSS, JS, IMAGES directories. I would prefer to not go thru the entire script changing the locations to match from the root. Is there a way in the ‘include’ so that it will use the directories beyond the uploader one instead of looking from the root?

All your includes need to be relative to the file you’re doing the includes in.

If your file is in /uploader, then any includes (assuming they aren’t outside that folder), need to relative to that folder. If its outside that folder, then you need to loose the …/, that tells it to backup one folder. Just use uploader/index.php instead.

All of the files that are used after the uploader/index.php are located n the uploader directory and its subs. Here’s the script for a clearer view:

<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="codebrush/css/demo.css" />
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/ajaxupload-min.js"></script>
		<link rel="stylesheet" href="codebrush/css/shCore.css" type="text/css" media="all" />
		<link rel="stylesheet" href="codebrush/css/shThemeEclipse.css" type="text/css" media="all" />
		<link rel="stylesheet" href="codebrush/css/shCoreDefault.css" type="text/css"/>
		<script src="codebrush/shCore.js" type="text/javascript"></script>
		<script src="codebrush/shBrushJScript.js"  type="text/javascript" ></script>
		<script src="codebrush/shBrushXml.js"  type="text/javascript" ></script>
		<script type="text/javascript">
			SyntaxHighlighter.all({toolbar:false});
		</script>
		
	</head>
	<body>
		<div>
			<?php 
				include 'php/basic.php';
			?>
		</div>
	</body>
</html>	

When run on its own all the css files and javascripts work properly. But when loaded from my main script with ‘include’ it cannot find the files

You need to add a ./ to the css path so it starts looking from where your at.

./codebrush/…

Sponsor our Newsletter | Privacy Policy | Terms of Service