Results 1 to 7 of 7

Thread: Display RAR Filename?

  1. #1
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question Display RAR Filename?

    Hi all

    Is it possiable to display a RAR filename on a PHP page from a directory?

    i.e i have name.php and i add welcome.rar to a directory on the server and the php automatically creates a new item within the php page

    before:

    item 1
    item 2

    After:

    welcome
    item 1
    item 2

    Thanks guys

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    I don't understand the question. Why does it matter what type of file it is? And how would you know which file if you don't know the filename? It seems like you just could use echo $filename;, assuming you have $filename defined for other reasons.

    Or do you want to actually know the contents or a .rar file? That would require an additional library, I think, and I've only done that for .zip files, but there's probably something for .rar files too. You can search for "read .rar php" and see what comes up.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    yer thanks, i forgot about echo lol (im not to good with php)

  4. #4
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    ok, i searched and searched but didnt find any that worked, my main goal here is:

    A page to display all the files in a certain folder and a link next to it to click so the user can download that (single) file.

    but it has to be php as it has to update itself automatically when a new file has been put into that directory.

    Thanks

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You should be able to adapt some of the code from this page:
    http://php.net/manual/en/function.readdir.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    PHP Code:
    $dir 'directory/you/want';
    foreach(
    scandir($dir) as $file)
    { echo 
    '<a href="'.$dir.'/'.$file.'">'.$file.'</a><br>'; } 
    If you want to force the file to be downloaded, that's a little more involved. HTML5 has a new attribute to force download but not all browsers support it yet.

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    If you want to force the file to be downloaded, that's a little more involved. HTML5 has a new attribute to force download but not all browsers support it yet.
    I don't think that would be relevant with .rar files-- no browser (that I know of) can view them natively, so they'd be saved (perhaps to a temporary directory, which would be allowed with force-download anyway) and extracted on the user's computer.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Resolved How to get Filename
    By mburt in forum PHP
    Replies: 1
    Last Post: 09-26-2011, 11:34 PM
  2. Replies: 8
    Last Post: 03-28-2009, 07:16 AM
  3. using filename for thumbs, PHP Photo Album
    By rapdigital in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-13-2009, 11:43 AM
  4. PHP randomizer show file and filename
    By Feldt in forum Looking for such a script or service
    Replies: 5
    Last Post: 07-24-2008, 11:41 PM
  5. append filename
    By Tabo in forum PHP
    Replies: 5
    Last Post: 05-16-2007, 07:42 PM

Bookmarks

Posting Permissions

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