Its Possible Or Not?

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

    Its Possible Or Not?

    Its Possible Or Not.

    Example.

    Url =http://some.com/ab/cd/ef/file.mp4

    But i want 2 show 'cd' directory

    Any code/idea for this

    $somthing = somthing code

    echo $something;

    Then its output like :
    cd

    #2
    Originally posted by PranaY4U View Post
    Its Possible Or Not.

    Example.

    Url =http://some.com/ab/cd/ef/file.mp4

    But i want 2 show 'cd' directory

    Any code/idea for this

    $somthing = somthing code

    echo $something;

    Then its output like :
    cd
    You're trying to hide the actual location of the files in your site, if I'm not wrong, Its very much possible with mod_rewrite & readfile or fopen/fread

    But it will eat a bit of more resource than normal

    If you files are saved in this location http://some.com/ab/cd/ef/file.mp4

    Then make a index.php & .htaccess file in cd directory

    in .htaccess


    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^([a-z0-9]+\.(mp4|3gp|png)$) index.php?file=$1 [NC,L]
    #The allowed extensions are in the brackets (mp4|3gp|png) you can add more or remove
    The index.php file

    PHP Code:
    <?
    /**
     * Setting time limit to 0 is important, if file is huge in size, 
     * the download will stop since by default the max execution of a PHP script is 30 secs
     */
    set_time_limit(0);
    if (!isset($_GET['file'])) :
        exit();
    else :
        $file = $_GET['file']; //The file suppiled in the URL
        $actual_directory = "/var/www/dl/files/";
        $actual_physical_file = $actual_directory . $file;
        //Check if the file actually exists there
        if (!file_exists($actual_physical_file)) :
            exit("No such file found!");
        else :
            //This block of code excutes when the file is physically found
            //Give the proper headers & send it the browser for download
            header("Content-Type: application/octet-stream");
            header('Content-Disposition: attachment; filename="' . $file . '"');
            header('Content-Length: '. filesize($actual_physical_file));
            readfile($actual_physical_file);
             //file output starts
             //The user will see a fake URL in his download manager, At that location the file never existed
        endif;
    endif;
    The file is served from this location http://localhost/dl/file.ext

    You can download this archive to try a demo
    Attached Files
    I need some facebook likes, can you please help me
    http://facebook.com/softwarefreakin
    I noticed social media is really powerful
    Well DONE is better than well SAID

    Comment

    Working...
    X