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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:54:53+00:00 2026-06-06T18:54:53+00:00

I have store a sample document inside my local server named template.doc. Then I

  • 0

I have store a sample document inside my local server named template.doc. Then I store the file directory inside my sqlite table. I manage to call out the path of the file directory but how can I allow the user to download it?

Codes

    <form id="List" name="List" method="post" action="">
          <select name="List" id="List">
                       <?php 
            if ($Choice !="No")
            {
                            $path = $_SERVER['DOCUMENT_ROOT']."/WEB/";
                $fullPath = $path.$_GET['$Choice'];
                                echo "<form id=\"form7\" name=\"form7\" method=\"post\" action=\"\">";
                echo "<input type=\"submit\" name=\"Download\" id=\"Download\" value=".$fullPath."/>";

                if (file_exists($fullPath)) 
                {
                    header('Content-Description: File Transfer');
                    header('Content-Type: application/octet-stream');
                    header('Content-Disposition: attachment; filename='.basename($fullPath));
                    header('Content-Transfer-Encoding: binary');
                    header('Expires: 0');
                    header('Cache-Control: must-revalidate');
                    header('Pragma: public');
                    header('Content-Length: ' . filesize($fullPath));
                    ob_clean();
                    flush();
                    readfile($fullPath);
                    echo "<label>".$fullPath."</label>";
                    echo "<input type=\"submit\" name=\"Download\" id=\"Download\" value=".$fullPath."/>";
                    exit;
                                            echo '</form>';
                }
            }
            ?>

How to create a button below the list form and download the microsoft word? It now flushes out the Microsoft word text on the website now, not on the button.
Kindly advise if it’s possible to do it. Just for local testing. Thanks alot!

  • 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-06T18:54:55+00:00Added an answer on June 6, 2026 at 6:54 pm

    You can use readfile and set the appropriate headers to force a download.

    Example from readfile domestication page:

    <?php
    $file = 'monkey.gif';
    
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
        exit;
    }
    ?>
    

    Your form should look something like this

    <form name="download" action="download.php" method="post">
        <input type="hidden" name="fileID" value="some file identifier" />
        <input type="submit" name="submit" value="Download File" />
    </form>
    

    Then, in download.php

    if(isset($_POST["submit"])) {
        $file = $_POST['fileID'];
        // download file
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting a new project where I have to parse a document and store
I have the created a sample Lucene code snippet which indexes a small file.
I need to parser an Xml Document and store the values in Text File,
I'm working on SQL server 2005 and I have a very simple stored procedure:
In my app, I have a simple ASCII file which stores some config info
I have to store a string (non-numeric, can contain any UTF8 Chars) in a
I found one sample application from the Blackberry knowledgebase. From that application I have
Sample HTML Data <body style=width:300px;> <h3>Long-Text</h3> A simple tool to store and display texts
I have this simple Select box that is suppose to store the selected value
I have a document with an embedded document in it. I have 2 forms,

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.