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

  • Home
  • SEARCH
  • 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 9175105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:51:39+00:00 2026-06-17T16:51:39+00:00

How do I specify the file to be downloaded from the database? main.php: include(‘databaseConnection.php’);

  • 0

How do I specify the file to be downloaded from the database?

main.php:

    include('databaseConnection.php');

    $result = mysql_query("SELECT * FROM participants");

    while($row = mysql_fetch_array($result)){


$download_me= $row['cv'];

echo $row['name'] . " " . $row['area_of_exp'] . " " ;

echo "<a href='download.php?file=$download_me'> cv </a>";

echo "<br />";
  }

download.php (which is where the problem lies):

$file = $_GET['row["cv"]'];  
header('Content-Disposition: attachment; filename="'.$file.'"');
echo $file;

I want the CV to be downloaded when the link in main.php is clicked

  • 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-17T16:51:39+00:00Added an answer on June 17, 2026 at 4:51 pm

    In the case your file is indeed in side your database you could retrieve it this way:

    Main.php:

    <?php
      $host = "hostname";
      $user = "username";
      $password = "password";
      $database = "database";
    
      $link = mysqli_connect($host, $user, $password, $database);
      If (!$link){
          echo ("Unable to connect to database!");
      }
      else {
      $query = "SELECT * FROM participants";    
      $result = mysqli_query($link,$query);
    
      while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)){
    
    echo $row['name'] . " " . $row['area_of_exp'] . " " . '<a href="download.php?file='.$row['id_participants']. '"\>'." cv </a><br />";
      }
    
    
    }
    mysqli_close($link);
    ?>
    

    mysql & more specific version:

    <?PHP
          include('databaseConnection.php');
    
    
          $query = "SELECT * FROM participants";    
          $result = mysql_query($query);
    
          while ($row = mysql_fetch_array($result, MYSQL_BOTH)){
    
        echo $row['name'] . " " . $row['area_of_exp'] . " " . '<a href="download.php?file='.$row['id_participants']. '"\>'." cv </a><br />";
          }
    
          mysql_close($link);
        ?>
    

    download.php:

    <?php
    
    
    $id_participants = $_GET['file'];
    
    $host = "hostname";
    $user = "username";
    $password = "password";
    $database = "database";
    
    $link = mysqli_connect($host, $user, $password, $database);
    If (!$link){
          echo ("Unable to connect to database!");
      }
      else {
    $query = "SELECT * FROM participants WHERE id_participants = $id_participants";
    
    $result = mysqli_query($link, $query);
    $row = mysqli_fetch_array($result, MYSQLI_BOTH);
    $size = $row['File_Size'];
    $type = $row['File_Type'];
    $name =$row['File_Name'];
    $CV = $row['cv'];
    // echo $size . "". $type . " ". $name;
    
    header("Content-length: $size");
    header("Content-type: $type");
    header("Content-Disposition: attachment; filename=$name");
    echo $CV;
    
    }
    mysqli_close($link);
    
    ?>
    

    Mysql & more specific:

    <?php
    
    include('databaseConnection.php');
    
    $id_participants = $_GET['file'];
    
    
    $query = "SELECT * FROM participants WHERE id_participants = $id_participants";
    
    $result = mysql_query($query);
    $row = mysql_fetch_array($result, MYSQL_BOTH);
    $size = $row['File_Size'];
    $type = $row['File_Type'];
    $name =$row['File_Name'];
    $CV = $row['cv'];
    // echo $size . "". $type . " ". $name;
    
    header("Content-length: $size");
    header("Content-type: $type");
    header("Content-Disposition: attachment; filename=$name");
    echo $CV;
    
    }
    mysql_close();
    
    ?>
    

    The database layout:

    CREATE TABLE IF NOT EXISTS `participants` (
      `id_participants` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(30) NOT NULL,
      `area_of_exp` varchar(30) NOT NULL,
      `cv` blob NOT NULL,
      `File_Size` varchar(30) NOT NULL,
      `File_Type` varchar(30) NOT NULL,
      `File_Name` varchar(30) NOT NULL,
      PRIMARY KEY (`id_participants`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
    

    http://www.sqlfiddle.com/#!2/91cb3/4

    I advice you to not store the CV in your database.

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

Sidebar

Related Questions

1) If inside CSS file we specify the following style: td { text-align:center; }
I know you can specify a different layout file for orientation by creating a
I have a configuration file where a developer can specify a text color by
in a java webstart file (jnlp) you can specify the nativelib tag to load
I'm trying to specify a relative directory in the web.xml file. I basically want
I have got a single file in which I need specify classes in multiple
Anyone know how to specify a custom record delimiter in a schema.ini file? I
I am using Padrino and when I try to specify my application.sass file I
In an .obj, file it is possible to specify 3 values for a vt
I make navigator through XML navigation file, and I specify the default action for

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.