var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Problem with recording a picture in database
Is there my problem:
I have a picture recorded in database with this method:
I read this data like this:
UPDATE myTable SET pictureData = (SELECT * FROM OPENROWSET(BULK 'myFileAdress.jpeg', SINGLE_BLOB)AS x ) WHERE …
In another hand I try directly read this picture file from a Php script as following:
$myData = $myConnection -> query ( 'Select pictureData from myTable where …' );
$row = $myData -> fetch ( PDO :: FETCH_ASSOC );
echo @ pack ( 'H*' , $row [ 'pictureData' ])
In fact some octet ('0') are placed with the first method (from the database) and corrupt my picture as seen in the two screenshots joined.
$data = fopen ( $myPictureAdress , 'rb' );
$size = filesize ( $picture );
echo fread ( $data , $size );
Does anyone knows why this octets are placed there ? Do the insert query is right done?
Thanks a lot for your help!
SQL Server 2005
Hello ,I'm not sure of your way to read the binary picture from the data base ,Because i'm asp.net developer So i'm using file streaming way .To insert and also to extract from data base ,Also there is another way ,May help you which store pic at folder and just store the path to it at DB .
may I'm helpful
Sorry ,About your code to insert i thought it is almost correct ,but may you need to mention the full path for an imageas below code:
For inserting images in to database i used the following code
BulkColumn from Openrowset( Bulk 'F:\Images\picture005.jpg', Single_Blob) as tt
In fact, that is what is really done, expect I didn't write it for the example given. Also we choose to record data in database for the reason to have all data recoverable or manageable at a time.
Originally Posted by
thanks a lot Paultech to thought about my problem.
Tags for this Thread