Activity Stream
48,167 MEMBERS
6791 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 10 of 44

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    Quote Originally Posted by Lock Down View Post
    Here is one I did not write just tweaked to add download... You can pass a path or place file in the folder you want the download the files.
    PHP Code: 
    <?php
    function download($filename)
    {
    $err '<p style="color:#990000">Sorry, the file you are requesting is unavailable.</p>';
    if (!
    $filename) {
    // if variable $filename is NULL or false display the message
            
    echo $err;
        } else {
            
    // define the path to your download folder plus assign the file name
            
    $path $filename;
            
    // check that file exists and is readable
            
    if (file_exists($path) && is_readable($path)) {
                
    // get the file size and send the http headers
                
    $size filesize($path);
                
    header('Content-Type: application/octet-stream');
                
    header('Content-Length: '.$size);
                
    header('Content-Disposition: attachment; filename='.$filename);
                
    header('Content-Transfer-Encoding: binary');
                
    // open the file in binary read-only mode
                // display the error messages if the file can?t be opened
                
    $file = @ fopen($path'rb');
                if (
    $file) {
                    
    // stream the file and exit the script when complete
                    
    fpassthru($file);
                    exit;
                } else {
                    echo 
    $err;
                }
            } else {
                echo 
    $err;
            }
        }
    }

    // block any attempt to the filesystem
    if (isset($_GET['file']) && basename($_GET['file']) == $_GET['file']) {
        
    $filename $_GET['file'];
        
    download($filename);
    } else {
        
    $filename NULL;
    }
    if (isset(
    $_GET['path']) && basename($_GET['path']) == $_GET['path']) {
        
    $path =  $_GET['path'];
        
    download($filename);
    } else {
    $path getcwd();
    }
    // open this directory
    $myDirectory opendir($path);

    // get each entry
    while($entryName readdir($myDirectory)) {
    $dirArray[] = $entryName;
    }

    // close directory
    closedir($myDirectory);

    // count elements in array
    $indexCount count($dirArray);

    // sort them
    sort($dirArray);
    ?>

    <html>
    <body>
    <table style="margin-bottom: 1px;" border="0" cellpadding="6" cellspacing="1" width="90%">
    <tbody>
    <tr>
    <th class="TableData" style="padding-left: 11px; padding-right: 1px;"
    bgcolor="#dadce1" width="300" height="22">File Name
    </th>

    <th class="TableData" style="padding-left: 11px; padding-right: 1px;"
    bgcolor="#dadce1" width="100" height="22">File Size
    </th>

    <th class="TableData" style="padding-left: 11px; padding-right: 1px;"
    bgcolor="#dadce1" width="350" height="22">Date Uploaded
    </th>

    <th class="TableData" style="padding-left: 11px; padding-right: 1px;"
    bgcolor="#dadce1" width="110" height="22">Download
    </th>

    <?php
    for($i=0$i $indexCount$i++) {
    // don't list hidden files
    if (substr("$dirArray[$i]"01) != "."){

    ?>

    <tr>
    <td class="Lebels" align="right" bgcolor="#e9ece9" >
    <?php echo $dirArray[$i]; ?> 
    </td>
    <?php
    print("<td bgcolor=\"#e9ece9\">");
    // We may want a file size. Note that you need to add path
    if( filesize$path "/" $dirArray[$i] ) >= 1024 ) {
    // Size in kilobytes
    print " " roundfilesize$path "/" $dirArray[$i] ) / 1024). " K<br />\n";
    } elseif( 
    filesize$path "/" $dirArray[$i] ) >= 1048576 ) {
    # Size in megabytes
    print " " roundfilesize$path "/" $dirArray[$i] ) / 1024 1024) . " M<br />\n";
    } else {
    // Size in bytes
    print " " filesize$path "/" $dirArray[$i] ) . " bytes<br />\n";
    }
    print(
    "</td>");
    ?>

    <td class="Values" bgcolor="#e9ece9" ><?php echo date ("F d Y H:i:s."filemtime($path "/" $dirArray[$i])); ?>
    </td>

    <td class="Values" bgcolor="#e9ece9" >
    <?php print("<a href='".$_SERVER['PHP_SELF']."?path=".$path."&file=".$dirArray[$i]."'>".$dirArray[$i]."</a>");?>

    </td>
    </tr>
    <?php
    }
    }

    print(
    "</TABLE>\n");
    ?>
    </body>
    </html>

    Thank You Lock Down your script is working but I do not understand where that folder path will add?
    softpk Reviewed by softpk on . I need Script Php Hello, sir i need directory listing php script what can you do? for example: File Name || Size || Upload Date || Download Button || Edit || Delete Thank You Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    no sir how to add directory path

    like this:

    PHP Code: 
    <?php
    function download($filename)
    {
    $err '<p style="color:#990000">Sorry, the file you are requesting is unavailable.</p>';
    if (!
    $filename) {
    // if variable $filename is NULL or false display the message
            
    echo $err;
        } else {
            
    // define the path to your download folder plus assign the file name
            
    $path =  http://yoursite.com/scriptname.php?path=/home/yourname/public_html/yourfolder;
            // check that file exists and is readable
            
    if (file_exists($path) && is_readable($path)) {

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Selling] Excellent Matrimonial Script| Complete readymade Matrimony Script Available
    By matriscript4u in forum Marketplace (Buy, Sell and Trade)
    Replies: 0
    Last Post: 23rd Oct 2012, 02:54 PM
  2. Replies: 12
    Last Post: 13th Mar 2012, 02:23 PM
  3. Greasemonkey script: Megaupload Premium Multifetch Script
    By Dman in forum Webmaster Resources
    Replies: 46
    Last Post: 15th Dec 2011, 01:07 AM
  4. [Selling] Rslinkgens Premium link generator script V1 -Most advanced and viral script
    By vccshopper in forum Completed Transactions
    Replies: 0
    Last Post: 24th Jun 2011, 08:10 PM
  5. [Selling] A.A.S. (Adult Automated Script For ClipBucket Video Script)
    By tangi in forum Completed Transactions
    Replies: 0
    Last Post: 25th Mar 2011, 12:45 PM

Tags for this Thread

BE SOCIAL