> Jeff:
>
> I apologise for not being clearer in my original email, but
> the data is
> already stored in a variable, $in{'file'}, which has already
> parsed the
> data from a web-form file upload field. I assumed that I
> could just issue
> the Binmode() on this variable and insert it into the
> database at this
> stage. It is not a local file that I am reading into the database.
>
> Of course, I understand that I can take this web-received
> information,
> save it to a file, open the file through the script and
> stream it to the
> database via Binmode(), but that seems awfully redundant.
>
> Based on this new info, what am I doing wrong, or is it
> necessary for me
> to save the web-form data to a file first and then stream the
> data into
> the database?
Brad --
1) Please always keep dbi-users on the reply list. You'll get better
support than through just me.
2) Binmode takes as an argument a file handle and ensures you read in
binary mode. That's all it does. It doesn't read the file or change
the data. Try just $in{'file'}, if that's where you read the data to,
but make sure where you read the data from has it in binary mode (may be
automatic in the way you get it, but I'm not sure)
Jeff
>
> Brad Smith
>
>
> On 6 Dec 2002 at 21:34, Jeff Urlwin wrote:
>
> > Ok, y'all built my confidence up enugh to set up this test
> > > script, but it
> > > isn't working. Can someone decipher what I am still doing wrong
> > > inserting a BLOB in a Access database?
> > >
> > > <code here>
> > >
> > > my $dbh = DBI->connect("dbi:ODBC:test") || die
> DBI::errstr; my $sth
> > > = $dbh->prepare("INSERT INTO test (attachment1)
> > > VALUES (?)
> > > ") || die DBI::errstr;
> > > $sth->bind_param(1,binmode($in{'file'}),
> > > DBI::SQL_LONGVARBINARY);
> > > $sth->execute;
> > > $dbh->disconnect();
> >
> >
> > Binmode doesn't read the file, it just sets the read mode of a the
> > file. Read the file into a variable, then insert it. Note, in my
> > longbin, there's a function that does this and returns the
> contents of
> > the file.
> >
> > Regards,
> >
> > Jeff
> >
> >
> >
>
>
>