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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:24:30+00:00 2026-06-08T22:24:30+00:00

I am trying to make a file downloadable in Safari. This is my code:

  • 0

I am trying to make a file downloadable in Safari.
This is my code:

<?php
$file = $_GET['file'];
header ("Content-Disposition: attachment");
header ("Content-type: application/octet-stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>

It works fine in FF but in Safari I get a 0kb file.

I think I there is something wrong in the header I am sending.
What could be the error?

  • 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-08T22:24:31+00:00Added an answer on June 8, 2026 at 10:24 pm

    Try This.

    <?php
    $file = $_GET['file'];
    header('content-type: application/octet-stream');
    header('content-Disposition: attachment; filename='.$file);
    header('Pragma: no-cache');
    header('Expires: 0');
    readfile($file);
    ?>
    

    Beware: Relying on $_GET['file'] without any sanitation or restrictions is very dangerous. Can be used to compromise the entire server application!

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

Sidebar

Related Questions

I'm trying to make File Downloads with WGET method of nodejs. I found this:
I was trying to make a file upload form and checked the PHP documentation
I'm trying to make a batch file to publish the few ClickOnce application we
I'm trying to make a file manager application where I list the contents of
I am trying to create a file with PHP here is my code: $file_to_send
I am trying to make this function download file from the internet. I pass
I am trying to make a new file format for music. It needs to
I'm trying to make an installation file of some eclipse package for linux. I
I'm trying to make a batch file through Notepad to essentially automate a process
I am trying to make an xml file to export my data from my

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.