CFFileUpload with inserting a record
Hi guys,
I'm bumping into the wall with this one. What i'm trying to do is using cffileupload tag upload multiple files, resize and rename them, and then insert into database the file name. All goes well until the last bit (insert into database). Have no clue where it goes wrong hence a call for help.
<cffileupload url="process.cfm?id=#URL.upd#" align="center" width="700" maxuploadsize = "200" progressbar = "true" bgcolor="white" oncomplete="printFileName" />
process.cfm:
<cfparam name="URL.id" default="1">
<cfquery name="get_photos" datasource="IGES">
SELECT *
FROM event_photos
WHERE event_id = <cfqueryparam value="#URL.id#" cfsqltype="cf_sql_numeric">
ORDER BY id DESC
</cfquery>
<cfset currentDirectory = #expandPath("../images/events/#URL.id#/")#>
<cfif DirectoryExists(currentDirectory)>
<cfelse>
<cfdirectory action="Create" directory="#expandPath("../images/events/#URL.id#/")#" mode="777">
</cfif>
<cffile
action = "upload"
destination = "#expandpath('../images/events/#URL.id#/')#"
nameconflict="makeunique"
>
<cfimage action="resize"
width="640"
height="480"
source="#expandpath("../images/events/#URL.id#/#file.serverfile#")#"
destination="#expandpath("../images/events/#URL.id#/#file.serverfile#")#"
overwrite="yes">
<cffile action = "rename"
source="#expandpath("../images/events/#URL.id#/#file.serverfile#")#"
destination="#expandpath("../images/events/#URL.id#/5.jpg")#">
<cfquery name="newrecord" datasource="iges" >
INSERT INTO event_photos (photo)
VALUES ("3")
</cfquery>
What happens is it uploads the file, resizes it, renames it and then gives me "status code = 50" error. What am I doing wrong? photo field in database is integer.
cheers,
Simon
