Displaying images stored in SQL Server

Is there someway of displaying images stored within SQL
Server. Is FDS required? Prefer a method to display images without
using FDS; Web Service would be okay if that can work

I do that sort of thing using PHP and mySQL the binary part
of the image is stored in a BLOB field (Binary Large OBject) along
the rest of the information necessary for the http headers (e.g.
mime type, file name, file size) being staored in their own fields.
That info is then used to build the file using PHP. The PHP
file contains a mySQL query whos result is echoed with the
appropriate headers. The URL points at the PHP file rather than at
any saved image.
Here's the php:
<?
# display_imagebank_file.php
# Note: the ID is passed through the url e.g.
# this_files_name.php?id=1
# connect to mysql database
mysql_connect('HOST', 'USERNAME', 'PASSWORD');
mysql_select_db('DATABASE');
# run a query to get the file information
$query = mysql_query("SELECT FileName, MimeType, FileSize,
FileContents FROM blobTable WHERE ID='$id'");
# perform an error check
if(mysql_num_rows($query)==1){
$fileName = mysql_result($query,0,0);
$fileType = mysql_result($query,0,1);
$fileSize = mysql_result($query,0,2);
$fileContents = mysql_result($query,0,3);
header("Content-type: $fileType");
header("Content-length: $fileSize");
header("Content-Disposition: inline; filename=$fileName");
header("Content-Description: from imagebank");
header("Connection: close");
echo $fileContents;
}else{
$numRows = mysql_num_rows($query);
echo "File not found <br>";
echo $numRows;
echo " is the number of rows returned for id = ";
echo $ID;
?>
Hope that helps
Phil

Similar Messages

  • Problems displaying images stored in SQL Server as Datatype "image"

    I am trying to display an Image stored in SQL Server as
    datatype
    'image' and it only shows a portion of the image.
    It seems to be tied to the size (kb) of the image since the
    larger the
    image the less of it is shown before it cuts off(sometimes it
    cuts off
    mid line so it's about the file size and not fitting the
    image on the
    screen).
    Here is the code I am using that deals with the image.
    [Bindable]
    public var theImage:ByteArray = new ByteArray;
    private function getScans_result(event:ResultEvent):void{
    var imageByteArray:ByteArray = event.result[0].Image;
    theImage = imageByteArray
    <mx:Image id="theIMG" width="160" height="220"
    source="{theImage}"/>
    Any Thoughts??

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Report - Unable to display image stored on External server

    Hi
    I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
    Please help me , Thx in advance.
    Ranga

    From the documentation:
    URL Reference
    1.Insert a dummy image in your template.
    2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{'http://image location'}
    For example, enter: url:{'http://www.oracle.com/images/ora_log.gif'}
    Element Reference from XML File
    1.Insert a dummy image in your template.
    2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full URL to the image.
    You can also build a URL based on multiple elements at runtime. Just use the concat function to build the URL string. For example:
    url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
    where SERVER, IMAGE_DIR, and IMAGE_FILE are element names from your XML file that hold the values to construct the URL.
    This method can also be used with the OA_MEDIA reference as follows:
    url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}
    Edited by: stevencallan on Feb 13, 2009 3:50 PM

  • Report - Not able to display image stored on External server or internet

    Hi
    I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
    Please help me , Thx in advance.
    Ranga

    Hi,
    I've got the same problem.
    Did you find any solution?
    Thank you
    Davide

  • Need suggestion on image storing in SQL Server

    Hi All,
      I want to store image into a column. I would like to know which datatype is the best to store image and which file format(bmp,jpg,png,...) is the best to store and to retrieve.We are using SQL Server 2005 Enterprise Edition.
      Waiting for valuable replies.
     Thanks and Regards
     Sridhar.R

    That is right but the OP mentioned that he uses SQL Server 2005.... BTW IMAGE data type  is still presented in SQL Server 2012 :-)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Displaying Images Stored on a Server In Flex

    My original idea for my app was to have live thumbnails of websites by screenshotting a html component in the app and saving these screenshots as jpgs which are applied as the source of the thumbnails. I now realise this is a bit too unstable as if the site doesn't load the images won't display. What I want to do instead is use the same idea but instead of the application writing to the application directory writing to a server where the images are stored so that it will overwrite these images.
    What I need to know is how to display server stored images in flex in either an image component or an array collection so they can be applied to a tilelist. The problem is I have zero experience at using server side data with flex. Can anyone point me in the direction to some examples/tutorials on how to display server stored data or more specifically images within a flex application or give me advice on this? Cheers.

    quick and easy way to do it would be with PHP.
    Make a script, scan a server folder and return the results in an XML format that can simply be fed into a datagrid/tilelist/whatever. To give you a few hints of what to look into.
    You'll need an initial HTTPService request fired off to the php script. The PHP script will then need to parse through the folder finding all the images, i'd recommend the glob() function in PHP to do this. eg:
    print "<images>";
    foreach (glob("directory/*.jpg") as $filename) {
        print "<screen><name>".$filename."</name><location>directory/".$filename."</location></screen>"
    print "</images>";
    then you'll need to handle the result event, simply feed each item into its respective place and ta daa.
    there are loads of examples around with this same methodology principle like this one:
    http://www.vipercreations.com/tutorials.php?t=28&page=1&c=Adobe%20Flex
    and i'm sure if you search around for 'flex php gallery' on google you'll probably even find a totally relevant example.

  • Display images from a SQL database

    I want to display images from a SQL database. The images are in a table under a specific column and are stored as a link to the image. How would I display the images from the column in LabVIEW?
    I'm using LabVIEW 2013 version 13 and SQL Server 2012
    Paul Power
    I have not lost my mind, it's backed up on a disk somewhere

    Hi PauldePaor,
    I hope you are well.
    Once you have pulled the data from the database into LabVIEW in a string form (or path), you can simply use the Read BMP File (Or jpg, png depending on the file type) VI.
    More information can be found here:
    http://digital.ni.com/public.nsf/allkb/02971A30F5D8FC6986256A0A004F11A0
    Kind Regards,
    Aidan H
    Applications Engineer
    National Instruments UK & Ireland

  • Can you store an Image in MS SQL Server 2005

    Hello,
    How possible is it to store customer uploaded images to MS SQL Server 2005.
    Any examples and is there a down turn to retrieving the data from the DB?

    How possible is it to store customer uploaded images to MS
    SQL Server 2005.
    Yes, you can store binary data in a BLOB (varbinary) column. Google turns up tons of hits on "storing images in sql server 2005". For example
    http://www.databasejournal.com/features/mssql/article.php/3719221/Storing-Images-and-BLOB- files-in-SQL-Server.htm
    Any examples
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Images_05.html
    is there a down turn to retrieving the data from the DB?
    It requires more database storage. So it can bloat your database. Plus there is the resources involved in retrieving the images from the database. Usually, it is better to just store the file path and save the actual image files on the file system.

  • JAVA, sqlserver - Need to load an image from the sql server database

    hi,
    I need to load an image from the sql server database using java. I have connected to the database and getting all other records except the records for a photo (datatype = LONGVARBINARY) and Remarks (datatype = LONGVARCHAR).
    I am using java and sql server db. The photo and remarks are stored in the db. and i need to show the image and the remarks fetching them from there.
    I get the error :
    Thread-9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
    How can I achieve this?
    Thanks,
    Gargi

    Exactly. And are you using MySQL?
    No. You are using Microsoft SQL server if I have to believe your initial post. A quick google tells me that the dialect class to use is:
    org.hibernate.dialect.SQLServerDialect

  • How to export an image column from SQL server to an excel

    Hi team,
    Would like to know how can i get an Image column storeed in SQL Server database to get copied in Excel (Hard Drive).
    Requirement : Need to get Username, User email address and User photo in to an excel sheet from SQL server database.
    Fix: I can get Username and Useremail adress however could not find a way to export /Copy user Image.
    Please suggest
    Thanks,
    venkatesh

    This is an Oracle forum. Your question relates to SQL Server and Excel, neither of which are Oracle related.

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Import IMAGE type from SQL Server to BLOB in Oracle

    Hello,
    Is there a way to import a IMAGE type from SQL Server to BLOB type in Oracle from one table to another through a database link?
    I'm waiting for an answer as soon as possible.
    Best regards,
    Florin
    Edited by: Florin Manole on Sep 10, 2008 11:53 AM

    Have you already configured a Heterogeneous Services and Generic Connectivity to create a database link from Oracle to SQL Server? I haven't tried copying IMAGE data from SQL Server via Heterogeous Services myself, but from the [data type map|http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/apb.htm#sthref509] in the documentation, I would expect that it would work so long as the SQL Server ODBC driver maps the IMAGE data type to SQL_LONGVARBINARY
    Justin

  • Display image stored @ content managemenbt

    Hi,
    this is regarding to displaying image stored @ content management, using <html:img> tag in .jsp
    under a node i am uploading two images. (node having two upload options)
    in .jsp i am using <html:img> tag to display the images.
    i tried to display both the images. But the first image what i upload is not showing. what i upload second is displaying.
    pls let me know how to resolve this.
    Thanks.

    You need to access binary property values separately from the node. In 9.2 the API is accessed via INodeManager.getStream(). Alternatively you can take advantage of the tags we have for this as well. Take a look here on edocs:
    http://e-docs.bea.com/wlp/docs92/cm/developCM.html
    -Ryan

  • How to save image files into SQL Server?

    Hello, All:
    Does anyone know how to save image files into SQL Server? Does the file type have to be changed first?? Please help me! Thank you!

    You need a BLOB field (usually)... Then you can check this tutorial out:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/
    There are other exercises on that site, including one on reading the images back.

  • Display BLOB Images from a  SQL Server DB

    I am using Crystal Reports X and SQL Server 2000.  I have a table (TABLE_PICS) that contains images (the images are stored in the DB.  I have another table (TABLE_NAMES) where each record references its related image by an ID. 
    What I want to do is create a report where I display each record from TABLE_NAMES with their associated TABLE_PICS images.
    I created a report, and the link is valid, but the report only displays a thumbnail and the name of the image.
    1.  Can someone tell me how I can get the actual images to appear?
    2.  I would prefer the images not be stored in the DB.  Can someone tell me how I can get the images on the report as explained above, without the images being in the DB.
    TIA,
    Jack

    I am using Crystal Reports X and SQL Server 2000.  I have a table (TABLE_PICS) that contains images (the images are stored in the DB.  I have another table (TABLE_NAMES) where each record references its related image by an ID. 
    What I want to do is create a report where I display each record from TABLE_NAMES with their associated TABLE_PICS images.
    I created a report, and the link is valid, but the report only displays a thumbnail and the name of the image.
    1.  Can someone tell me how I can get the actual images to appear?
    2.  I would prefer the images not be stored in the DB.  Can someone tell me how I can get the images on the report as explained above, without the images being in the DB.
    TIA,
    Jack

Maybe you are looking for