Jump to content

Recommended Posts

I have created a table in a MySQL database to hold Word doc CVs of Employees stored in a Blob.

          CREATE TABLE EmployeeCV

          ( id INT NOT NULL AUTO_INCREMENT,

            EmailAddress varchar(40) NOT NULL,

            name VARCHAR(30) NOT NULL,

            type VARCHAR(30) NOT NULL,

            size INT NOT NULL,

            content MEDIUMBLOB NOT NULL,

            PRIMARY KEY(id),

          )

I have no trouble uploading the CVs to the database but I am unable to download and display the CVs. I am using the EmailAddress of EmployeeCV as a key for finding a particular CV. Here is the simplified html file for submitting the email address:

<html>

<body>

<form name="Input Employee Email For CV.html"

          action="Get Employee CV.php" method="post">

 

<p>Type Employee's email address:

<input type="text" name="emailaddress"><br></p>

 

<input type="submit" value="Submit" name="SubmitButton">

 

</form>

</body>

</html>

 

Below is the php code for downloading the Word docs. I have tried modifying the code several times but with no success.

<html>

<body>

<?php

  if(isset($_POST['SubmitButton']))

  { //connection string

    $con = mysql_connect("hostserver.net","user","pswrd");

    mysql_select_db("db", $con);

 

    $email = mysql_real_escape_string($_POST[' emailaddress']);

    $sql = "SELECT name, type, size, content FROM EmployeeCV ".

                  "WHERE EmailAddress = '$email'";

    $res = mysql_query($sql) or die('Error, query failed');

 

    list($name, $type, $size, $content) = mysql_fetch_array($res);

    header("Content-length: $size");

    header("Content-type: $type");

    header("Content-Disposition: attachment; filename=$name");

    //echo $content;

?>

<iframe src="$content"></iframe>

<?php

  mysql_close($con);

    exit;

  }

?>

</body>

</html>

Each time I get the following warning and error:

Warning: Cannot modify header information - headers already sent by (output started at..........

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator,............

I wonder if someone could offer me a solution. I would be very grateful.

 

Link to comment
https://forums.phpfreaks.com/topic/154578-cannot-download-word-doc-from-database/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.