Skip to main content
Participant
August 19, 2008
Question

Need Help With File Upload

  • August 19, 2008
  • 3 replies
  • 482 views
Hi Guys,

I am new to Cold Fusion. Please help me out.
I have written a code to upload a .doc file into SQL Server 2000. SQL Server 2000 has only Text data type for files.
The code uploads the file fine.
When it is trying to insert the fie to the database it is throwing an error.



Throws an error for data mismatch.
---------------------------
Invalid data {TIMECREATED={ts '2008-08-19 16:09:55'}, FILEWASAPPENDED=false, FILEWASRENAMED=true, FILEWASOVERWRITTEN=false, CLIENTDIRECTORY=Admin.txt, OLDFILESIZE=85, CONTENTTYPE=text, CONTENTSUBTYPE=plain, ATTEMPTEDSERVERFILE=Admin.txt, CLIENTFILEEXT=txt, DATELASTACCESSED={d '2008-08-19'}, FILEWASSAVED=true, FILEEXISTED=true, CLIENTFILENAME=Admin, SERVERFILE=Admin5.txt, CLIENTFILE=Admin.txt, FILESIZE=85, SERVERDIRECTORY=C:\, SERVERFILENAME=Admin5, SERVERFILEEXT=txt, TIMELASTMODIFIED={ts '2008-08-19 16:09:55'}} for CFSQLTYPE CF_SQL_CHAR.

The error occurred in \\l-ny-shegde\web\workspace\ETS\application\ets\includes\FAW\getSetBlob.cfm: line 52

50 : (<cfqueryparam
51 : value="#file#"
52 : cfsqltype="cf_sql_text">)
53 :
54 : <!--- insert into file_data (filedata)

---------------------------
This topic has been closed for replies.

3 replies

Inspiring
August 20, 2008
FILE is a reserved word in CF. Do NOT name your variables FILE.

your <cfqueryparam ... value="#file#"> actually inserts all the keys of
#file# (same as #cffile#) structure into your table, not the value of
your variable named "file".

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
HSahAuthor
Participant
August 19, 2008
Thanks for the reply.
I am trying to save the doc itself in the database.

So should I store the file as a varbinary field in the database ?

In SQL Server 2000 there is no data type as blob. The closest I found for uploading files was text for chars and ntext for unicode chars.



Inspiring
August 20, 2008
cf_sql_text is not a valid cfsqltype. You may try cf_sql_longvarchar.

Please see cfqueryparam livedocs.
Inspiring
August 19, 2008
Are you sending the location of the DOC file to SQL server as a reference? or are you trying to store the actual DOC file in the database?

If the latter, a Word Doc is a binary file and therefore would require such a field. You will also likely have to turn on BLOB and CLOB availability in CF Admin.