How to insert file blob into sql database

I am try to upload file and save into sql database and also retrieve b

Page 1 of 1

7 Replies - 41145 Views - Last Post: 14 September 2009 - 08:51 AM Rate Topic: -----

#1 cindyn  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 12-September 07

How to insert file blob into sql database

Post icon  Posted 12 September 2007 - 01:25 PM

:rolleyes: <cffile action="upload"
filefield="form.FileName"
destination="C:\temp\"
nameconflict="makeunique"
accept="application/octet-stream, application/vnd.ms-excel">

<cffile
action = "readbinary"
file = "C:\temp\#cffile.serverFile#"
variable="file_blob">

<cfquery name="add" datasource="#dsn#">
insert into ICE (file_content)
values (
<cfqueryparam
value="#file_blob#"
cfsqltype="cf_sql_blob">

Is This A Good Question/Topic? 1

Replies To: How to insert file blob into sql database

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: How to insert file blob into sql database

Posted 12 September 2007 - 08:57 PM

Okay, and...what's the problem?
Was This Post Helpful? 0
  • +
  • -

#3 cindyn  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 12-September 07

Re: How to insert file blob into sql database

Posted 13 September 2007 - 04:11 AM

View Postgirasquid, on 12 Sep, 2007 - 08:57 PM, said:

Okay, and...what's the problem?


From the code, I have the "cfcatch" for error message

<cfcatch type="application">
You've got an error!
</cfcatch>


The problem is when I upload the file, the error message display and the file doesn't save in database.
I can not find the problem. Please advise.
Thanks
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to insert file blob into sql database

Posted 13 September 2007 - 04:35 AM

whats the Data Type of the column you're trying to save the file in? Is this mySQL, MSSQL, Oracle?
Was This Post Helpful? 0
  • +
  • -

#5 cindyn  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 12-September 07

Re: How to insert file blob into sql database

Posted 13 September 2007 - 05:27 AM

View PostPsychoCoder, on 13 Sep, 2007 - 04:35 AM, said:

whats the Data Type of the column you're trying to save the file in? Is this mySQL, MSSQL, Oracle?



The data type is blob, here is my table:
SQL> create table ICE (
2 file_id raw(16) default sys_guid() primary key,
3 file_content blob)
4 /

I would like to insert all different type of file into database and retrieve back. The user will upload file to database and dowload back for viewing if need.
Now I having a problem with the upload.
Thanks for any help.
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to insert file blob into sql database

Posted 13 September 2007 - 05:47 AM

View Postcindyn, on 13 Sep, 2007 - 05:27 AM, said:

View PostPsychoCoder, on 13 Sep, 2007 - 04:35 AM, said:

whats the Data Type of the column you're trying to save the file in? Is this mySQL, MSSQL, Oracle?



The data type is blob, here is my table:
SQL> create table ICE (
2 file_id raw(16) default sys_guid() primary key,
3 file_content blob)
4 /

I would like to insert all different type of file into database and retrieve back. The user will upload file to database and dowload back for viewing if need.
Now I having a problem with the upload.
Thanks for any help.


Is this mySQL, MSFT SQL or Oracle?
Was This Post Helpful? 0
  • +
  • -

#7 cindyn  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 12-September 07

Re: How to insert file blob into sql database

Posted 13 September 2007 - 05:49 AM

View PostPsychoCoder, on 13 Sep, 2007 - 05:47 AM, said:

View Postcindyn, on 13 Sep, 2007 - 05:27 AM, said:

View PostPsychoCoder, on 13 Sep, 2007 - 04:35 AM, said:

whats the Data Type of the column you're trying to save the file in? Is this mySQL, MSSQL, Oracle?



The data type is blob, here is my table:
SQL> create table ICE (
2 file_id raw(16) default sys_guid() primary key,
3 file_content blob)
4 /

I would like to insert all different type of file into database and retrieve back. The user will upload file to database and dowload back for viewing if need.
Now I having a problem with the upload.
Thanks for any help.


Is this mySQL, MSFT SQL or Oracle?


It is Oracle database using ColdFusion
Any help very appreciated.
Thanks

This post has been edited by cindyn: 13 September 2007 - 07:56 AM

Was This Post Helpful? 0
  • +
  • -

#8 hrpatel34  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-September 09

Re: How to insert file blob into sql database

Posted 14 September 2009 - 08:51 AM

View Postcindyn, on 13 Sep, 2007 - 04:49 AM, said:

View PostPsychoCoder, on 13 Sep, 2007 - 05:47 AM, said:

View Postcindyn, on 13 Sep, 2007 - 05:27 AM, said:

View PostPsychoCoder, on 13 Sep, 2007 - 04:35 AM, said:

whats the Data Type of the column you're trying to save the file in? Is this mySQL, MSSQL, Oracle?



The data type is blob, here is my table:
SQL> create table ICE (
2 file_id raw(16) default sys_guid() primary key,
3 file_content blob)
4 /

I would like to insert all different type of file into database and retrieve back. The user will upload file to database and dowload back for viewing if need.
Now I having a problem with the upload.
Thanks for any help.


Is this mySQL, MSFT SQL or Oracle?


It is Oracle database using ColdFusion
Any help very appreciated.
Thanks


Instead of <cfcatch type="application">
You've got an error!
</cfcatch>

use
<cfcatch type="application">
<cfdump var="#cfcatch#">
</cfcatch>

You will see whats your error is.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1