...

View Full Version : inserting image or other data in the database ??



PHPycho
04-02-2007, 12:25 PM
Hello forums !!
I know its not the best way to store mime data in the mysql but the database is designed so i have to go that way.
I didnt have the idea to store and retrieve the mime data in the mysql.
Can anybody guide me in such case ??
Thanks in advance to all of you !

Daemonspyre
04-02-2007, 01:22 PM
You will have to use LONGBLOB fields to store the binary data.

If you are using an uploader, like ASPUpload, you will have to store the binary data from the upload.form() method.

To retrieve the data, you will have to use a BinaryWrite or "application/" HTTP header to retrieve the data.

In ASP:


<%
Response.ContentType = "application/image-jpg" 'change to suit your file type
Response.BinaryWrite fldName
%>


In PHP:


<?php
$fpd = "path2file" . $fp . ".pdf";
$len = filesize($fpd);
header("Content-Type: application/pdf"); // change to suit your file type
header("Content-Disposition: inline; filename=$fpd");
header("Content-Title: $fpd");
header("Content-Length: $len");
readfile($fpd);
?>


You can also use this method to push PDF files (as seen above) and any other information that you feel necessary (Documents, Spreadsheets, Images, etc).

HTH!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum