raydona Posted April 18, 2009 Share Posted April 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/154578-cannot-download-word-doc-from-database/ Share on other sites More sharing options...
Maq Posted April 18, 2009 Share Posted April 18, 2009 I'm not sure about about the other errors, but read this sticky for the Headers error: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/154578-cannot-download-word-doc-from-database/#findComment-812830 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.