downloaded flv file is not playing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dinesh1985singh
    New Member
    • Apr 2010
    • 49

    downloaded flv file is not playing

    I downloaded a flv vedio file from server using php successfully, but when I tried to play the same downloaded file it was not playing..

    Also when I checked its time for which it being played in a player it showed me zero sec.

    What might be the problem?

    I want know how to sort out that problem,the same code is working for mp3 file without any error.

    Here is my code:
    Code:
    if(isset($_GET['id']))
     {
      echo $sql = "select * from file_details where file_id='".$_GET['id']."'";
    
      $rsl = mysql_query($sql) or die("Error! query failed");
      echo $name = stripslashes(mysql_result($rsl,0,'file_name'));
      echo $type = stripslashes(mysql_result($rsl,0,'file_type'));
      echo $path = stripslashes(mysql_result($rsl,0,'file_path'));
      echo $size = mysql_result($rsl,0,'file_size');
       header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private",false); 
        header("Content-Description: File Transfer");
        header("Content-Type: $type");
      
        header("Content-Disposition: attachment; filename=\"".$name."\";");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: ".$size);
        @readfile($path);
        exit;
     }
    could you please let me know what would i have to change so that the .flv vedio play too.

    thank you
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    a corrupt file? incomplete download?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      We can only make guesses without seeing the PHP code.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        remove the @ in line 20 (that prevents you from receiving errors)

        you must send the headers before any other output (should give you plenty of warnings otherwise), not afterwards.

        Comment

        • dinesh1985singh
          New Member
          • Apr 2010
          • 49

          #5
          thanks
          but its still not working,when I download the file its size after being download is 10.9 mb,same as the original one but in player it still shows 00:00 second while trying to play it after being downloaded.
          and it does show me any warning or error massages.
          Last edited by dinesh1985singh; May 4 '10, 12:15 PM. Reason: to few line

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            don’t echo the headers, this will render the file invalid.

            read also the user notes on the manual page of readfile().

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Also, remove that @ from line 20. It may be suppressing an error.

              Edit: sorry - didn't see that you'd already suggested that, Dorm.

              Comment

              • dinesh1985singh
                New Member
                • Apr 2010
                • 49

                #8
                Originally posted by Dormilich
                don’t echo the headers, this will render the file invalid.

                read also the user notes on the manual page of readfile().
                Thank you
                Dormilich and Markus you to .

                Now I can download a vedio files as well as can play too by following your instruction.

                The problem was the same as you told me and that is i echoed some data before calling headers.

                Great reply

                Thank you one more time

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  Glad you got it working, Dinesh.

                  For future reference, you should always develop a script with full error reporting by the PHP engine.

                  To do that, either set your php.ini configuration setting for error_reporting to -1, or put this at the top of your script: error_reporting (-1);.

                  Mark.

                  Comment

                  • Akshay Kumar Vi
                    New Member
                    • Apr 2011
                    • 2

                    #10
                    But Where is the Solution..? I have the same issue.. Please provide me a better solution for this..

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      The solution was to remove all output sent before calls to header().

                      Comment

                      Working...