Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    inserting image or other data in the database ??

    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 !

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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:
    Code:
    <% 
    Response.ContentType = "application/image-jpg" 'change to suit your file type
    Response.BinaryWrite fldName 
    %>
    In PHP:
    Code:
    <?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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •