Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9204955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:50:09+00:00 2026-06-17T23:50:09+00:00

I have a script that uploads outside of the webroot. Through the website I

  • 0

I have a script that uploads outside of the webroot. Through the website I then link users to images documents etc.

So for an image the link would be:

media.php?file=nameoffile.jpg&user=userid&folder=images

This is then used to display the image:

<img src="media.php?file=nameoffile.jpg&user=userid&folder=images" width="100" border="0">

This works fine for images and providing a link to download a document.

The problem I face is embedding, I use ffmpeg to convert all allowed videos types to flv (these videos are tested and working great), but when I try to embed the flv video it never works (it works with the direct link of the file just not through media.php). If possible I would also like to embed .swf.

I am using jwplayer to embed (works with the direct link of the file just not through media.php)

        <!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE --> 
            <object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="328" height="200"> 
            <param name="movie" value="player.swf" /> 
            <param name="allowfullscreen" value="true" /> 
            <param name="allowscriptaccess" value="always" /> 
            <param name="flashvars" value="media.php?file=nameoffile.flv&user=userid&folder=videos" /> 
            <embed 
                type="application/x-shockwave-flash"
                id="player2"
                name="player2"
                src="player.swf"
                width="328" 
                height="200"
                allowscriptaccess="always" 
                allowfullscreen="true"
                flashvars="file=media.php?file=nameoffile.flv&user=userid&folder=videos"
            /> 
            </object> 
            <script type="text/javascript" src="jwplayer.js"></script>
            <!-- END OF THE PLAYER EMBEDDING --> 

Here is media.php:

        $path_parts = pathinfo($_SERVER['REQUEST_URI']);
        $file = basename(urldecode($_GET['file']));
        $user = basename(urldecode($_GET['user']));
        $folder = basename(urldecode($_GET['folder']));
        $ext = pathinfo($file, PATHINFO_EXTENSION);

        $fileDir = 'pathoutsidewebroot';
        $filePath = $fileDir . $file;

        switch(
        $ext) {
            case "flv": $ctype="video/x-flv"; break;
            // adobe
            case "pdf": $ctype="application/pdf"; break;
            // ms office
            case "doc": $ctype="application/msword"; break;
            case "rtf": $ctype="application/rtf"; break;
            case "xls": $ctype="application/vnd.ms-excel"; break;
            case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
            // open office
            case "odt": $ctype="application/vnd.oasis.opendocument.text"; break;
            case "ods": $ctype="application/vnd.oasis.opendocument.spreadsheet"; break;
            default: $ctype = "application/force-download"; break; 
}

        if(in_array($ext, $valid_formats_vid)){
            if (file_exists($filePath)) {
                header('Content-Type: ' . mime_content_type($filePath));
                header('Content-Length: ' . filesize($filePath));
                readfile($filePath);
        }
        }

        else if(in_array($ext, $valid_formats_img)) {
            if (file_exists($filePath)) {
                header('Content-Type: ' . mime_content_type($filePath));
                header('Content-Length: ' . filesize($filePath));
                readfile($filePath);
            }
        }
        else if(in_array($ext, $valid_formats_docs)) {
                    if (file_exists($filePath))
                    {
            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: private",false);
            header("Content-Type: $ctype");
            header("Content-Disposition: attachment; filename=\"".basename($filePath)."\";");
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: ".@filesize($filePath));
            set_time_limit(0);
            @readfile($filePath) or die("File not found.");                 }
        }

Header from embed that is through media.php

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Disposition:filename=encoded_2012-10-19_22.37.09_1359032866.flv
Content-Length:0
Content-Type:video/x-flv
Date:Thu, 24 Jan 2013 16:26:32 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=88
Pragma:no-cache
Server:Apache/2.2.20 (Ubuntu)
X-Powered-By:PHP/5.3.6-13ubuntu3.8

Header from direct link to file (the one that works)

Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:2428614
Content-Type:video/x-flv
Date:Thu, 24 Jan 2013 16:23:54 GMT
ETag:"26ca3d8-250ec6-4d4087c796500"
Keep-Alive:timeout=5, max=100
Last-Modified:Thu, 24 Jan 2013 13:07:00 GMT
Server:Apache/2.2.20 (Ubuntu)

Managed to change it to this through media.php (but still not working)

            header("Content-Type: $ctype");
            header('Content-Length: ' . filesize($filePath));
            header('Accept-Ranges: bytes');
            $now = time( );
            $then = gmstrftime("%a, %d %b %Y %H:%M:%S GMT", $now + 365*86440);
            header("Expires: $then");
            ob_clean();
            flush();
            readfile($filePath);



Accept-Ranges:bytes
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Length:2428614
Content-Type:video/x-flv
Date:Thu, 24 Jan 2013 16:44:18 GMT
Expires:Fri, 24 Jan 2014 20:47:38 GMT
Keep-Alive:timeout=5, max=79
Pragma:no-cache
Server:Apache/2.2.20 (Ubuntu)
X-Powered-By:PHP/5.3.6-13ubuntu3.8
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:50:10+00:00Added an answer on June 17, 2026 at 11:50 pm

    I managed to get it working with the following, I also included a thumb image for the player (this was taken on upload through ffmpeg):

    header("Content-Type: $ctype");
    header('Content-Length: ' . filesize($filePath));
    header('Accept-Ranges: bytes');
    $now = time( );
    $then = gmstrftime("%a, %d %b %Y %H:%M:%S GMT", $now + 365*86440);
    header("Expires: $then");
    ob_clean();
    flush();
    readfile($filePath);
    
    
    $flv_path = 'media.php?file='.$row['cur_image'].'&folder=videos&user='.$row["posted_by"];
    
    $thumb = pathinfo($row['cur_image']);
    $thumb_path = 'media.php?file='.$thumb['filename'].'.jpg&folder=videos&user='.$row["posted_by"];
    ?>           
    
    
    <!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
    <div id="mediaplayer_<?php echo $row['p_id']; ?>">JW Player goes here</div>                           
    <script type="text/javascript">
                            jwplayer("mediaplayer_<?php echo $row['p_id']; ?>").setup({
                                flashplayer: "jwplayer/jwplayer.flash.swf",
                                file: "<?php echo $flv_path; ?>",
                                image: "<?php echo $thumb_path; ?>",
                                controlbar: "bottom",
                                width: "380",
                                height: "200",
                                primary: "flash",
                                type: "mp4",
                                controls: true,
                                allowscriptaccess: 'always'
                            });
    </script>
    <!-- END OF THE PLAYER EMBEDDING -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image upload script that batch uploads loads of images. I want
I have a script that uploads an image using JavaScript, as seen here .
For a client I have build a simple script that uploads multiple files(images), resizes
Hi I have an upload script that uploads images to a file, but I
Hello I have a script that uploads multiple images (this script is composed of
I have a php script that uploads a zip file of images to a
I have the follow script that uploads and image and a thumbnail to a
I have a PHP script that uploads a CSV file and then saves some
I have an upload script that uploads images to a server. I need a
I have a script that uploads a file and then moves it to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.