www.webdeveloper.com
Results 1 to 6 of 6

Thread: PHP list of folder with links problem D:

  1. #1
    Join Date
    Sep 2012
    Posts
    5

    Angry PHP list of folder with links problem D:

    Hello,
    I have a script that I found out in the internet and I tried alot of thinks but I cant find what's wrong.
    The script does a list of what's in a folder and then it makes links to that files but it links them wrong, it should link them to admin/upload/FILE
    and it just links them to href="FILE"

    PHP Code:

    <html>
        <head>
            <title>ObritSesam</title>
        </head>
    <center>
    <?php
     
    if ($handle opendir('admin/upload/')) {
       while (
    false !== ($file readdir($handle)))
          {
              if (
    $file != "." && $file != "..")
          {
                  
    $thelist .= '<a href="'.$file.'" target="_blank">'.$file.'</a><br>';
              }
           }
      
    closedir($handle);
      }
    ?>
    <P>Llista de archius:</p>
    <P><?=$thelist?></p>
    </center>
    </html>
    Thanks in advance!

  2. #2
    Join Date
    Sep 2012
    Posts
    5
    I correct myself here:

    "I have a script that I found out in the internet and I tried alot of thinks but I cant find what's wrong."
    to:
    I have a script that I found out in the internet and I tried alot of different things but I cant find what's wrong.

    Sorry for my bad english! D:

  3. #3
    Join Date
    Sep 2012
    Posts
    5
    I correct myself here:

    "I have a script that I found out in the internet and I tried alot of thinks but I cant find what's wrong."
    to:
    I have a script that I found out on the internet and I tried alot of different things but I cant find what's wrong.

    Sorry for my bad english! D:

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,245
    Just add the directory:
    PHP Code:
    $thelist .= '<a href="admin/upload/'.$file.'" target="_blank">'.$file.'</a><br>'
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Sep 2012
    Posts
    5
    Quote Originally Posted by NogDog View Post
    Just add the directory:
    PHP Code:
    $thelist .= '<a href="admin/upload/'.$file.'" target="_blank">'.$file.'</a><br>'
    Thank you!
    1 question, where should I put the target="_blank" here?
    PHP Code:
    print("<TR><TD><a href=\"admin/upload/$dirArray[$index]\">$dirArray[$index]</a></td>"); 

  6. #6
    Join Date
    Sep 2012
    Posts
    5
    Nvm! found myself how

    PHP Code:
    echo '<TR><TD><a href="admin/upload/'.$dirArray[$index].'" target="_blank">'.$dirArray[$index].'</a></td>'

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles