hi.
I'm having real problems using cffile in CF4.5. I have two pages, one to actually select an image and the other which has the cffile on it. what I want to do is to select an image, upload it to a specified directory, and store the image name in a table field for later use.
on the first page I have this code (the javascript was supplied by a third party, not written by me, so Ican't vouch for exactly what it's doing...)
<!--header-->
<CFQUERY DATASOURCE="seaportal" NAME="admin">
SELECT * FROM venue_information
WHERE venue_name = '#URL.venue_name#'
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="diary">
SELECT * FROM story_info
WHERE story_id = '#URL.story_id#'
</CFQUERY>
<SCRIPT LANGUAGE="JavaScript">
function getRealFileName(frm){
var theFile = frm.story_image.value;
var fullFileName = theFile.substring(theFile.lastIndexOf('\\') + 1, theFile.length);
frm.RealFileName.value = fullFileName;
frm.submit();
}
</SCRIPT>
then in the body, the actual form that selects the image is:
<cfoutput ...>
<form action="image_add_2.cfm" method="POST" ENCTYPE="multipart/form-data">
<table>
<tr><td>
<input type="hidden" name="story_id" value="#story_id#">
<input type="hidden" name="venue_name" value="#venue_name#">
<input type="hidden" name="RealFileName" value="">
<input type="file" size="30" name="story_image">
</td>
</tr>
<tr>
<td width="300" align="center"><input type="button" value="submit" onclick="getRealFileName(this.form);"></td>
<td width="356"><input type="reset" value="clear form"></td>
</tr>
</table>
</form>
</cfoutput>
and on the next page I have
<cfif form.story_image NEQ "">
<cfset theFile = "c:\inetpub\<cffile action="UPLOAD"
destination="#theFile#"
nameconflict="MAKEUNIQUE"
filefield="story_image"
accept="image/jpg, image/jpeg, image/gif"
>
<cfset var_thumbImage = "#FORM.realFileName#">
<cfelse>
<cfset var_thumbImage = "">
</cfif>
<CFQUERY DATASOURCE="seaportal">
INSERT INTO story_info
(story_image)
VALUES
('#var_thumbImage#')
WHERE story_id="#FORM.story_id#"
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="admin">
SELECT * FROM venue_information
WHERE venue_name = '#FORM.venue_name#'
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="diary">
SELECT * FROM story_info
WHERE venue_name = '#FORM.venue_name#' AND story_id = '#FORM.story_id#'
</CFQUERY>
at the moment I'm getting an error
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC Microsoft Access Driver] Missing semicolon (
at end of SQL statement.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (13:1) to (13:32).
(this occurs on image_add_2.cfm at the position of the query
<CFQUERY DATASOURCE="seaportal">
INSERT INTO story_info
(story_image)
VALUES
('#var_thumbImage#')
WHERE story_id = "#FORM.story_id#"
</CFQUERY>
anyone any ideas?
Ian
I'm having real problems using cffile in CF4.5. I have two pages, one to actually select an image and the other which has the cffile on it. what I want to do is to select an image, upload it to a specified directory, and store the image name in a table field for later use.
on the first page I have this code (the javascript was supplied by a third party, not written by me, so Ican't vouch for exactly what it's doing...)
<!--header-->
<CFQUERY DATASOURCE="seaportal" NAME="admin">
SELECT * FROM venue_information
WHERE venue_name = '#URL.venue_name#'
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="diary">
SELECT * FROM story_info
WHERE story_id = '#URL.story_id#'
</CFQUERY>
<SCRIPT LANGUAGE="JavaScript">
function getRealFileName(frm){
var theFile = frm.story_image.value;
var fullFileName = theFile.substring(theFile.lastIndexOf('\\') + 1, theFile.length);
frm.RealFileName.value = fullFileName;
frm.submit();
}
</SCRIPT>
then in the body, the actual form that selects the image is:
<cfoutput ...>
<form action="image_add_2.cfm" method="POST" ENCTYPE="multipart/form-data">
<table>
<tr><td>
<input type="hidden" name="story_id" value="#story_id#">
<input type="hidden" name="venue_name" value="#venue_name#">
<input type="hidden" name="RealFileName" value="">
<input type="file" size="30" name="story_image">
</td>
</tr>
<tr>
<td width="300" align="center"><input type="button" value="submit" onclick="getRealFileName(this.form);"></td>
<td width="356"><input type="reset" value="clear form"></td>
</tr>
</table>
</form>
</cfoutput>
and on the next page I have
<cfif form.story_image NEQ "">
<cfset theFile = "c:\inetpub\<cffile action="UPLOAD"
destination="#theFile#"
nameconflict="MAKEUNIQUE"
filefield="story_image"
accept="image/jpg, image/jpeg, image/gif"
>
<cfset var_thumbImage = "#FORM.realFileName#">
<cfelse>
<cfset var_thumbImage = "">
</cfif>
<CFQUERY DATASOURCE="seaportal">
INSERT INTO story_info
(story_image)
VALUES
('#var_thumbImage#')
WHERE story_id="#FORM.story_id#"
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="admin">
SELECT * FROM venue_information
WHERE venue_name = '#FORM.venue_name#'
</CFQUERY>
<CFQUERY DATASOURCE="seaportal" NAME="diary">
SELECT * FROM story_info
WHERE venue_name = '#FORM.venue_name#' AND story_id = '#FORM.story_id#'
</CFQUERY>
at the moment I'm getting an error
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC Microsoft Access Driver] Missing semicolon (
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (13:1) to (13:32).
(this occurs on image_add_2.cfm at the position of the query
<CFQUERY DATASOURCE="seaportal">
INSERT INTO story_info
(story_image)
VALUES
('#var_thumbImage#')
WHERE story_id = "#FORM.story_id#"
</CFQUERY>
anyone any ideas?
Ian