alwaysbrasilian Posted April 10, 2009 Share Posted April 10, 2009 This is such a basic thing that i feel a little embaressed but i need the help. I want to load an image from another site. also if i make a link inside the file.php('index.php') i can use it only while inside the index.php but if i want to use it in folder 2 it displays 'Not found.' I've tried '../' but then it only works inside folder2 and not index. You can see i tried using chdir, opendir, readdir and no luck. what function/command can i use for this? file.php <?php echo "Hello world!". "<br>"; echo getcwd(); ?> <img src="house1.jpg" /> <a href="index.php"> back to index </a> index.php <link rel="styleSheet" type="text/css" href="template.css" /> <body> <p>index</p> <a href="folder/folder/folder1/folder1.php"> folder 1 </a> <a href="folder2/folder2.php"> folder 2 </a> </body> folder2.php <?php chdir('/wamp/www/test'). "<br>"; print getcwd(); print opendir('/wamp/www/test'); include('file.php'); ?> <link rel="styleSheet" type="text/css" href="../template.css" /> <body> <p>folder2</p> </body> </html> Quote Link to comment Share on other sites More sharing options...
alwaysbrasilian Posted April 10, 2009 Author Share Posted April 10, 2009 bump from like page three Quote Link to comment Share on other sites More sharing options...
schilly Posted April 10, 2009 Share Posted April 10, 2009 link external image: <img src='http://externalimage.com/image.jpg'> for your stylesheet link just use the full path: http://www.yourdomain.com/template.css hope this is what you meant. Quote Link to comment Share on other sites More sharing options...
alwaysbrasilian Posted April 10, 2009 Author Share Posted April 10, 2009 not exactly. i have a file which lets call top.php inside folder main with other .php and html files. Now if I use the include function of php in my other .html/php files in different folders links and pictures wont display because file thinks its inside the main folder but in reality its two or three directories back and all links and pictures don't work unless i use '../' but inside the original folder with all other files it then wont work. So any ideas on how to link all files to top.php and still be able to use the links and pictures.. Quote Link to comment Share on other sites More sharing options...
schilly Posted April 11, 2009 Share Posted April 11, 2009 So any ideas on how to link all files to top.php and still be able to use the links and pictures.. yup. use the full path for your folder links and images. Quote Link to comment Share on other sites More sharing options...
alwaysbrasilian Posted April 11, 2009 Author Share Posted April 11, 2009 IT WORKS!!, i only understood relative path and didn't completely understand absolute path until now.. so simple i would kick myself if i could. All this time ive been trying '/wamp/www/main/top.php' and i never thought that if i used 'http://localhost/test/top.php' would work. thanks again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.