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 9034297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:26:23+00:00 2026-06-16T08:26:23+00:00

I have a video file which I need to grab using a function instead

  • 0

I have a video file which I need to grab using a function instead of a direct link.
When I view the video page code of the direct link, this is what I have on screen:

enter image description here

But when I use my function, first of all the video wont run, and when I view the code, this appears:

enter image description here

I realized it’s the same file, the same characters, but with many \0 characters in the middle. These are the one’s in yellow.

This is the code I’m using:

$file_name = --path to file--;
$file_size = filesize($file_name);
$ctype = 'video/mp4';

header('Content-Type: '.$ctype);
header('Content-Length: ' . $file_size);
header("Accept-Ranges: bytes");    
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');

$file = fopen($file_name, 'rb');
$read = fread($file, $file_size);
print($read);
fclose($file);
exit;

Do I need to change the code? Is there something to make fread read the file properly?
Or do I need to do some kind of processing to the file to be displayed?

  • 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-16T08:26:24+00:00Added an answer on June 16, 2026 at 8:26 am

    Try using readfile() instead of fopen()/fread()/fclose(). It will be more memory efficient and less susceptible to errors.

    Having said that there’s no real reason why your code shouldn’t work (assuming that the file path is correct) – you should (for once) ensure that display_errors is off in case a PHP error is corrupting the file. You can do this by setting ini_set('display_errors', 0); at the top of your script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a URL for a video file which I need to play using
I have a Windows Media Video file, and the need to grab a frame
I am making an app in which I have to play video file. .flv
I have an ASF file which contain 8 audios and 1 video. Now i
I have a flash video player which requests a flv file from a central
I have a project of video broadcasting in which I need to provide the
I have implemented video play functionality in iphone.In which i am downloading video file
I have some large files (images and video) which I need to store in
On windows, I have a dynamically created uncompressed avi video file which grows overtime.
I have a file called video_2.m4v on my computer, which is being used by

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.