Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
Can some one please take a look at this code and tell me what I'm doing wrong...
I've written this script which will list files in a folder and create a link for them... the only thing is, it only works if it's pulling files from a different folder... Also if there is another folder in there it won't link it properly...
This is the file in action... http://www.djantd.info/Tunes/Uniting_Nations/index.php
code: <?php
$path = "../Tunes/Uniting_Nations/";
if (strrpos($moverse,'..')) {
$moverse = str_replace('/..','',$moverse);
$moverse = substr($moverse,0,strrpos($moverse,'/'));
}
if($moverse) $moverse = $moverse."/";
echo $moverse.'<br>';
$handle=opendir($path.$moverse);
while ($file = readdir($handle)) {
if(is_dir($path.$moverse.$file) && $file != ".") {
if ($file == ".." && $moverse == "") {
} else {
echo "<a href='?moverse=".$moverse.$file."'>".$file."</a><br>";
echo('<br>');
}
} else if ($file != ".") {
echo "<a href='".$path.$moverse.$file."'>".$file."</a><br>";
echo('<br>');
}
}
?>
I want it to work like http://www.djantd.info/home.php?nav=mixes.php&t=Mixes
Exept, in that last example the folder called Uniting_Nations doesn't like right eitehr 
Cheers people!!
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Online
|
You need mod_rewrite for stuff like that.
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
what... just install that on the server and that'll sort it, or do I need to change me code too?
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
Is this really gonna be worth it? 
Maybe I'll just screw it and do it manually
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
does the directory exist? if not theres your reason lol
also chmod the directory(s) to 777, that might work, or change the path from "../Tunes/Uniting_Nations/" to "/home/sites/djantd.info/public_html/Tunes/Uniting_Nations/" 
Although from what i gather, your code looks alright
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
Yeah that directory is good, the file is actually in that directory
|
Tim
Site Administrator
Registered: 21st Apr 00
User status: Offline
|
Why is the path ../Tunes when the folder is just ./ relative to the php file?
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
Cos I use that code for other things, like my gallery and to pull files from folders in other locations.... just couldn't be arsed to modify it, I didn't think it would matter
|
Tim
Site Administrator
Registered: 21st Apr 00
User status: Offline
|
Well as you're using relative paths, you can't move the php file and the path still work
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
no, but isn't it only relative to the path I specify... I changed the folder... it's too confusing... I have a solution....
I just added the Uniting Nations Section to the existing file http://www.djantd.info/home.php?nav=mixes.php&t=Mixes
|
Antz
Member
Registered: 28th Jul 03
Location: Leeds Drives: Myself Insane!
User status: Offline
|
Cheers for your help people... I always take the easy road out
|