Jump to content

i cant load an image from another dir


alwaysbrasilian

Recommended Posts

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>

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.