
March 1st, 2005, 07:52 PM
|
|
Contributing User
|
|
Join Date: Oct 2004
Posts: 105
Time spent in forums: 4 h 41 sec
Reputation Power: 4
|
|
|
Help:Uploading an image and saving it in db.
Hi, I'm trying to upload an image from my webpage that i'm creating and inserting it into my database in access. But i'm having an error message that said: "Invalid data C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp20871.tmp,Upload for CFSQLTYPE CF_SQL_LONGBINARY."
Here is my code:
PHP Code:
<!--Insert a new product into the shoe table-->
<cflock name="InsertNewProduct" type="exclusive" timeout="30">
<cftransaction>
<cfquery name="AddProduct" datasource="shoes">
INSERT INTO shoe(manufactorID, brand, name, details, type, price, color, size)
VALUES('#form.manufactorID#', '#form.brand#', '#form.name#', '#form.details#', '#form.type#',
'#form.price#','#form.color#', '#form.size#')
</cfquery>
<!--This query retrieves the primary key value of the product we just inserted-->
<cfquery name="GetPK" datasource="shoes">
SELECT MAX(shoeID) AS MaxShoeID FROM Shoe
</cfquery>
</cftransaction>
</cflock>
<!--This query uses the value returned by the GetPK query to lookup the full product we inserted-->
<cfquery name="GetProduct" datasource="shoes">
SELECT shoeID, manufactorID, brand, name, details, type, price, imageURL, color, size FROM shoe
WHERE shoeID = #GetPK.MaxShoeID#
</cfquery>
<!---file upload--->
<cfif isdefined("form.imageURL")>
<cffile action="Upload"
filefield="imageURL"
destination="C:\Inetpub\wwwroot\soleshop"
nameconflict="makeunique"
accept="image/*">
<cfset upload_file= #file.serverfile#>
<cfoutput>#serverFile# successfully added. Size of the upload file:
#Numberformat(Evaluate(File.FileSize/1024))# KB.
</cfoutput>
</cfif>
<cfinsert datasource="shoes"
tablename ="shoe"
formfields="imageURL">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
</html>
Please help. Thanks!
|