in reply to Adding a JPEG file to database

Eliya ++

Good point about binding parameters, and specifying their types.

The other thing that occurs to me is that one call to read is not guaranteed to read the whole file. My understanding is that do to that you have to call read (or sysread) repeatedly until it returns zero. eg:

open(BLOB, $blob_file) ||die "Cannot open the blob file\n"; binmode BLOB; my $bytes = 0; my $offset = 0; my $buf; while( $bytes != 0 ) { $bytes = read(BLOB, $buf, 500000, $offset); die "Error reading $blob_file $!" unless defined $bytes } close BLOB; # $buf now contains all the bytes from $blob_file

See read on perldoc