Auto index help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Auto index help

    Hai Friends i want to make downloads website using autindex php code
    i found this script which can be placed inside folders to autmatic show files over page


    PHP Code:
    <?
    $items_per_page = "10";
    $size_bytes = 100072000;
    $kb = $size_bytes / 1024;
    $mb = $size_bytes / 1024000;
    if (!isset($_GET['page']))
    { $page=0; }
    else  { $page = $_GET['page']; }
    $total = 0;

        if(!($dp = opendir("./"))) die ("Cannot open ./");
    $file_array = array();
    while ($file = readdir ($dp))
        {
        if(substr($file,0,1) != '.' and $file != "index.php")
            {
            $file_array[] =  $file;
            }
        }
    $file_count = count ($file_array);
    sort ($file_array);

                    if ($file_count > 0)
                {
                $first_record = $page * $items_per_page;
                $last_record = $first_record + $items_per_page;

                while (list($fileIndexValue, $file_name) = each ($file_array))
                    {

                    if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
                        {

                        echo "&raquo; <a href=\"$file_name\"></a>$file_name<br/><a href=\"$file_name\">Download(". round(filesize($file_name)/1024,1) . "kb)</a><br />";
                        $total = $total + filesize($file_name);
                        
                        
                        }
                    }
                ?><hr><center><?
                
                if (($file_count > 0) AND ($page != 0))
                    {


                    
                    // previous button
                    
                    $prev_page = $page -1;
                    
                    echo "<a  href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page\">[Back]</a> | ";
                                   
                    }


                if (($file_count > 0) AND ($last_record < $file_count))
                    {
                    // next button
                    $next_page = $page + 1;
                    echo "<a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page\">[Next]</a>";
                    }
                    
                        
                    echo "<br/>Directory:<br/>$file_count ";
                if ($file_count == 1)
                    {echo "file";}
                else
                    {echo "files";}
                    
                echo " (" . round($total/1024,1) . "kb)";
                ?></div><?
                    // Home index
                    echo " <br/><a  href=\"http://write here your url\">[Edit Your Back Link]</a>";
                    
    /*
    -----------------------------------------------------------
    Please Support Us by providing back Link to Our Site,
    Don't delete this partner link.
    ----------------------------------------------------------
    */
                    
                    echo " <br/>Our Partner:";
                
                                
     echo " <br/><a  href=\"http://pocketwap.net\">[Pocketwap.net]</a><hr>"; 
                    
                    
                }
                
            closedir($dp);
            
            ?>
    This is nice and usefull also but i want to make one change wheneve i click on download on images download i got reirect to http://mysite/imaeg/image.gif
    insted of redirectin i want to make it direct downloadble means someone clicks on that download link and its starts doownloading automaticly i hope someone will understand what i am trying to say
    ComputerForumz - Latest Tech News


    Mobbest.tk-Free Mobile Downloads

    #2
    Its not redirect as this is just directory listing script, that is the link to the file.
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    Comment


      #3
      you should make a PHP script that forces a download,
      PHP Code:
      <?php

      header
      ('Content-type: application/YOUR_EXTENSION');


      header('Content-Disposition: attachment; filename="downloaded.YOUR_EXTENSION"');

      echo 
      file_get_contents(YOUR_FILE_PATH);
      hope that helps!

      Comment

      Working...
      X