mflagstad
asked on
CFFILE UPLOAD Subscriber Issues
Here's the problem. I have a subscription service. Each member, after paying, is assigned an account number, and then chooses a username and password. The entire back end is using a very simple, but effective security framework that consists of an application.cfm file and this:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
on each page.
We need the ability for the subscriber to upload multiple files to their account that only can be viewed by them. There are about 8 different sections that have file upload capabilities (eg, A, B, C, D, etc.) If they upload files to category A, only those files can be listed under A on the file viewing page. Other files that have been uploaded to other categories are also listed on the same file viewing page under their respective headings, A, B, C, D, etc.
The member should also have the ability to rename the file, delete the file, or add another file to the same category.
We used to have it set up this way by uploading the files using their usernames, but since we added the additional security, this is no longer feasible.
Thanks, Michelle mflagstad@ila-media.com
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
on each page.
We need the ability for the subscriber to upload multiple files to their account that only can be viewed by them. There are about 8 different sections that have file upload capabilities (eg, A, B, C, D, etc.) If they upload files to category A, only those files can be listed under A on the file viewing page. Other files that have been uploaded to other categories are also listed on the same file viewing page under their respective headings, A, B, C, D, etc.
The member should also have the ability to rename the file, delete the file, or add another file to the same category.
We used to have it set up this way by uploading the files using their usernames, but since we added the additional security, this is no longer feasible.
Thanks, Michelle mflagstad@ila-media.com
ASKER
Ok that code helps with one part of the question, but I am still having problems coding for the member to upload anywhere, let alone a specific folder.
This is what I have for the page where files can be uploaded:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<cfquery name="getinfo" datasource="mydsn">
Select * from med
WHERE AccountNumber='#session.Ac countNumbe r#'
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "file1.cfm" enctype="multipart/form-da ta" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F ORM></cfou tput>
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="fileview.cfm" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
However, this won't allow me to do anything...I get an error message:
Error processing CFFILE
The directory specified in the DESTINATION attribute of the CFFILE tag (c:\inetpub\wwwroot\111457 79060\) is not valid. The directory either does not exist or is not accessible by the ColdFusion service.
The error occurred while processing an element with a general identifier of (CFFILE), occupying document position (61:1) to (63:26).
I guess I'm trying to upload using their account number, but that's not working, so how do I do this? Where do I identify a spot for member uploads and how do I pull only their info for their viewing, not all of the uploads?
Thanks,
Michelle
This is what I have for the page where files can be uploaded:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<cfquery name="getinfo" datasource="mydsn">
Select * from med
WHERE AccountNumber='#session.Ac
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "file1.cfm" enctype="multipart/form-da
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="fileview.cfm" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
However, this won't allow me to do anything...I get an error message:
Error processing CFFILE
The directory specified in the DESTINATION attribute of the CFFILE tag (c:\inetpub\wwwroot\111457
The error occurred while processing an element with a general identifier of (CFFILE), occupying document position (61:1) to (63:26).
I guess I'm trying to upload using their account number, but that's not working, so how do I do this? Where do I identify a spot for member uploads and how do I pull only their info for their viewing, not all of the uploads?
Thanks,
Michelle
why don't you create a directory for each subscriber using <cfdirectory > tag ?
you can do like
<cftry>
.... put all your current code here ...
<cfcatch>
.... create the directory if it didn't exist
.... do all the other code ...
</cfcatch>
</cftry>
you can do like
<cftry>
.... put all your current code here ...
<cfcatch>
.... create the directory if it didn't exist
.... do all the other code ...
</cfcatch>
</cftry>
ASKER
I have no idea what you mean...any sample code?
thanks, Michelle
thanks, Michelle
<CFDIRECTORY ACTION="create"
DIRECTORY="c:\inetpub\appl icationnam e\users\"
NEWDIRECTORY="#userID#">
DIRECTORY="c:\inetpub\appl
NEWDIRECTORY="#userID#">
ASKER
I have no idea what you mean...any sample code?
thanks, Michelle
thanks, Michelle
ASKER
I have no idea what you mean...any sample code?
thanks, Michelle
thanks, Michelle
ASKER
So do you mean like this?
efile upload page:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<cftry>
<cfcatch>
<CFDIRECTORY ACTION="create"
DIRECTORY="c:\inetpub\wwwr oot\users\ "
NEWDIRECTORY="#AccountNumb er#">
<cfquery name="getinfo" datasource="mydsn">
Select * from med
WHERE AccountNumber='#session.Ac countNumbe r#'
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "viewfile.cfm" enctype="multipart/form-da ta" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F ORM></cfou tput>
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="fileview.cfm" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
</cfcatch>
</cftry>
and then for fileview page:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName') AND TRIM(New_FieldName) NEQ ''><!--- Upload --->
<CFIF ACT EQ "EDIT"><!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#mydsn#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#" ACCOUNTNUMBER="#AccountNum ber#">
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del _Img.New_F ile#')>
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N ew_File#">
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')><!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,' .')>
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE RVERFILE#" DESTINATION="#FilePath##Ne wFileName# .#FILEEXT# ">
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE><!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH>
</CFCATCH>
</CFTRY>
<CFQUERY name="Upd_Table">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</cfif>
Does this make sense at all? b/c I have no idea what I'm doing here....
thanks,
michelle
efile upload page:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<cftry>
<cfcatch>
<CFDIRECTORY ACTION="create"
DIRECTORY="c:\inetpub\wwwr
NEWDIRECTORY="#AccountNumb
<cfquery name="getinfo" datasource="mydsn">
Select * from med
WHERE AccountNumber='#session.Ac
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "viewfile.cfm" enctype="multipart/form-da
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="fileview.cfm" method="post">
<input type = "hidden" name="accountnumber" value = "#accountnumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
</cfcatch>
</cftry>
and then for fileview page:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"><!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#mydsn#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#" ACCOUNTNUMBER="#AccountNum
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')><!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE><!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH>
</CFCATCH>
</CFTRY>
<CFQUERY name="Upd_Table">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</cfif>
Does this make sense at all? b/c I have no idea what I'm doing here....
thanks,
michelle
yes - if u wish to have a dir for each users - then they cld upload it to their own dir
chk first if the dir is present or not - if not create it - if its there then just upload the file in the dir - the code for create dir given to u is fine & shld do it for u
<cfif not directoryexists('c:\inetpu b\wwwroot\ users\#Acc ountNumber #')>
<CFDIRECTORY ACTION="create"
DIRECTORY="c:\inetpub\wwwr oot\users\ "
NEWDIRECTORY="#AccountNumb er#">
</CFIF>
let me know ...
K'Rgds
Anand
chk first if the dir is present or not - if not create it - if its there then just upload the file in the dir - the code for create dir given to u is fine & shld do it for u
<cfif not directoryexists('c:\inetpu
<CFDIRECTORY ACTION="create"
DIRECTORY="c:\inetpub\wwwr
NEWDIRECTORY="#AccountNumb
</CFIF>
let me know ...
K'Rgds
Anand
ASKER
I got the efile.cfm to work, but the viewfile is getting this error message:
Error Diagnostic Information
Attribute set validation error in tag CFQUERY
The tag has an invalid attribute combination: the most likely attribute combinations are
Required attributes: 'DBTYPE'. Optional attributes: 'BLOCKFACTOR,CACHEDWITHIN, CONNECTSTR ING,DATASO URCE,DBNAM E,DBPOOL,D BSERVER,DE BUG,MAXROW S,NAME,PAS SWORD,PROV IDER,PROVI DERDSN,SQL ,TIMEOUT,U SERNAME'.
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDWITHIN, CONNECTSTR ING,DBNAME ,DBPOOL,DB SERVER,DBT YPE,DEBUG, MAXROWS,NA ME,PASSWOR D,PROVIDER ,PROVIDERD SN,SQL,TIM EOUT,USERN AME'.
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDAFTER,C ONNECTSTRI NG,DBNAME, DBPOOL,DBS ERVER,DBTY PE,DEBUG,M AXROWS,NAM E,PASSWORD ,PROVIDER, PROVIDERDS N,SQL,TIME OUT,USERNA ME'.
Other possible combinations are
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDAFTER,DEBUG,MAXROWS ,SQL,TIMEO UT'.
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDWITHIN,DEBUG,MAXROW S,SQL,TIME OUT'.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (26:5) to (26:30).
This is the code for that page:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName') AND TRIM(New_FieldName) NEQ ''><!--- Upload --->
<CFIF ACT EQ "EDIT"><!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del _Img.New_F ile#')>
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N ew_File#">
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')><!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,' .')>
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE RVERFILE#" DESTINATION="#FilePath##Ne wFileName# .#FILEEXT# ">
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE><!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH>
</CFCATCH>
</CFTRY>
<CFQUERY name="Upd_Table">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</cfif>
Any suggestions?
Error Diagnostic Information
Attribute set validation error in tag CFQUERY
The tag has an invalid attribute combination: the most likely attribute combinations are
Required attributes: 'DBTYPE'. Optional attributes: 'BLOCKFACTOR,CACHEDWITHIN,
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDWITHIN,
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDAFTER,C
Other possible combinations are
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDAFTER,DEBUG,MAXROWS
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDWITHIN,DEBUG,MAXROW
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (26:5) to (26:30).
This is the code for that page:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"><!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')><!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE><!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH>
</CFCATCH>
</CFTRY>
<CFQUERY name="Upd_Table">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</cfif>
Any suggestions?
hi replace the code with this
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName') AND TRIM(New_FieldName) NEQ ''> <!--- Upload --->
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del _Img.New_F ile#')>
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N ew_File#">
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,' .')>
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE RVERFILE#" DESTINATION="#FilePath##Ne wFileName# .#FILEEXT# ">
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY >
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
let me know
K'Rgds
Anand
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select New_File from medlife where New_File = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N
</CFIF>
<CFSET New_File = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_File" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE
<CFSET New_File = "#NewFileName#.#FILEEXT#">
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#New_File#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
let me know
K'Rgds
Anand
ASKER
Ok now it appears as though the file is uploading, however, it won't show up in a list as it is supposed to in viewfile.cfm (the code that you gave me above) The entire page is blank? No error messages or anything like that, just a blank page...
ASKER
I've been thinking about this issue, and I think there's a problem with the code on the efile.cfm page. Don't I have to pass the info regarding the category that the upload is supposed to go into? Also, should have I created an additional field(s) in the database for any of this?
Also, I looked in the server and none of the files that I thought were uploading were...there is nothing on the server and there is a blank page for viewfile...any suggestions here? I'm losing my mind over this...
Also, I looked in the server and none of the files that I thought were uploading were...there is nothing on the server and there is a blank page for viewfile...any suggestions here? I'm losing my mind over this...
hi,
ok cool it ... chillax - it will work ... dont worry abt it - ive done this 100's of times & it has to WORK !
firs thigns :
1. ive used certain variables in my eg - which need to be initialisd in ur code as well - since i wasnt aware abt the path & all - ive used variables for them
2. my file fieldname is diff from ur's & since i am checking for isdefined - its not appearing in ur case
chk up on these & iam sure thigns shld be fine !
K'Rgds
Anand
ok cool it ... chillax - it will work ... dont worry abt it - ive done this 100's of times & it has to WORK !
firs thigns :
1. ive used certain variables in my eg - which need to be initialisd in ur code as well - since i wasnt aware abt the path & all - ive used variables for them
2. my file fieldname is diff from ur's & since i am checking for isdefined - its not appearing in ur case
chk up on these & iam sure thigns shld be fine !
K'Rgds
Anand
ASKER
OK, what variables do I need in here?
the dsn is medlife
the path is c:\inetpub\wwwroot\fpdb\me dlife.mdb
i don't have any fieldnames set up in the database for anything to do with the uploads. Should I? If so, what are the field names I should set up that match your code? How can I make the files appear in a hyperlinked state in a list under their respective categories? I cannot figure this out! :) Please help....
michelle
the dsn is medlife
the path is c:\inetpub\wwwroot\fpdb\me
i don't have any fieldnames set up in the database for anything to do with the uploads. Should I? If so, what are the field names I should set up that match your code? How can I make the files appear in a hyperlinked state in a list under their respective categories? I cannot figure this out! :) Please help....
michelle
no no no ...
i didnt mean that ur DB conenctions has some problems in it - what i meant was :
1. chk the name of the "file field" on ur form - the one ur using to provide the upload utility to the user - use that name instead of "New_File" in my code
2. "#FilePath#" in my code corresponds to teh path where the file wld be uploaded - intiliase it with appropriate path as per ur project so that it points to : "d:\clients\urprojfolder\u ploaddir\" [this cld be whatever u have decided for ur project]
rest it shld work fine
K'Rgds
Anand
i didnt mean that ur DB conenctions has some problems in it - what i meant was :
1. chk the name of the "file field" on ur form - the one ur using to provide the upload utility to the user - use that name instead of "New_File" in my code
2. "#FilePath#" in my code corresponds to teh path where the file wld be uploaded - intiliase it with appropriate path as per ur project so that it points to : "d:\clients\urprojfolder\u
rest it shld work fine
K'Rgds
Anand
ASKER
Still not working and I am going crazy....
here is the form page:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<cfquery name="getinfo" datasource="medlife">
Select * from med
WHERE AccountNumber='#session.Ac countNumbe r#'
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "viewfile.cfm" enctype="multipart/form-da ta" method="post">
<input type = "hidden" name="AccountNumber" value = "#session.AccountNumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F ORM></cfou tput>
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="viewfile.cfm" method="post">
<input type = "hidden" name="AccountNumber" value = "#session.AccountNumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
here is the viewfilepage.cfm where the list should show up:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName') AND TRIM(New_FieldName) NEQ ''> <!--- Upload --->
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select filename from medlife where filename = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#AccountNumber ##Del_Img. filename#' )>
<CFFILE ACTION="DELETE" FILE="#AccountNumber##Del_ Img.filena me#">
</CFIF>
<CFSET filename = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#AccountNumbe r#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,' .')>
<CFFILE ACTION="RENAME" SOURCE="#AccountNumber##FI LE.SERVERF ILE#" DESTINATION="#AccountNumbe r##filenam eName#.#FI LEEXT#">
<CFSET filename = "#filenameName#.#FILEEXT#" >
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY >
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#filename#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
As for creating the directory to where the files should be uploaded, I thought that was done by creating a folder of their AccountNumber and placing the files in there? When I look on the server, that folder has been created, yet this is still not working, it is just giving me a blank viewfile page. In the space for the file path, would I have to make it like: c:\inetpub\wwwroot\#Accoun tNumber#?
That would be the physical path...
except, i just tried that:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName') AND TRIM(New_FieldName) NEQ ''> <!--- Upload --->
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select filename from medlife where filename = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#c:\inetpub\ww wroot\Acco untNumber# #Del_Img.f ilename#') >
<CFFILE ACTION="DELETE" FILE="#c:\inetpub\wwwroot\ AccountNum ber##Del_I mg.filenam e#">
</CFIF>
<CFSET filename = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#c:\inetpub\w wwroot\Acc ountNumber #" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,' .')>
<CFFILE ACTION="RENAME" SOURCE="#c:\inetpub\wwwroo t\AccountN umber##FIL E.SERVERFI LE#" DESTINATION="#c:\inetpub\w wwroot\Acc ountNumber ##filename Name#.#FIL EEXT#">
<CFSET filename = "#filenameName#.#FILEEXT#" >
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY >
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#filename#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
and I got this:
Just in time compilation error
Invalid parser construct found on line 9 at position 64. ColdFusion was looking at the following text:
:
Invalid expression format. The usual cause is an error in the expression structure.
The last successfully parsed CFML construct was a CFIF tag occupying document position (9:15) to (9:19).
The specific sequence of files included or processed is:
C:\Inetpub\wwwroot\member\ security\v iewfile.cf m
What can I do to make this work?????????????
sorry i'm such an idiot about all this, I'm sure it's supposed to be easy, but I must have a synapse missing in my brain....
michelle
here is the form page:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<cfquery name="getinfo" datasource="medlife">
Select * from med
WHERE AccountNumber='#session.Ac
</cfquery>
<CFOUTPUT QUERY = "GETINFO">
<FORM action = "viewfile.cfm" enctype="multipart/form-da
<input type = "hidden" name="AccountNumber" value = "#session.AccountNumber#">
<P align=center><B><font size="2">Other Medical Records:</font></B></P>
<P align=center><font size="2">
<input type="file" size="20" name="filename"><br>
<INPUT type=submit value=Store></font></P></F
<FONT
size=3>
<P align="center">
<cfoutput query="getinfo">
<form action="viewfile.cfm" method="post">
<input type = "hidden" name="AccountNumber" value = "#session.AccountNumber#">
<p align="center">
<input type="submit" value="Click Here to view your medical files"> </p>
</form>
</cfoutput>
</cfif>
here is the viewfilepage.cfm where the list should show up:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select filename from medlife where filename = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#AccountNumber
<CFFILE ACTION="DELETE" FILE="#AccountNumber##Del_
</CFIF>
<CFSET filename = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#AccountNumbe
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#AccountNumber##FI
<CFSET filename = "#filenameName#.#FILEEXT#"
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#filename#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
As for creating the directory to where the files should be uploaded, I thought that was done by creating a folder of their AccountNumber and placing the files in there? When I look on the server, that folder has been created, yet this is still not working, it is just giving me a blank viewfile page. In the space for the file path, would I have to make it like: c:\inetpub\wwwroot\#Accoun
That would be the physical path...
except, i just tried that:
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"> <!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Select filename from medlife where filename = #Image_File#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#c:\inetpub\ww
<CFFILE ACTION="DELETE" FILE="#c:\inetpub\wwwroot\
</CFIF>
<CFSET filename = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#c:\inetpub\w
<CFIF ISDEFINED('Rename')> <!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#c:\inetpub\wwwroo
<CFSET filename = "#filenameName#.#FILEEXT#"
<CFELSE>
<!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH></CFCATCH></CFTRY
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update Table set ImageName = '#filename#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
</CFIF>
and I got this:
Just in time compilation error
Invalid parser construct found on line 9 at position 64. ColdFusion was looking at the following text:
:
Invalid expression format. The usual cause is an error in the expression structure.
The last successfully parsed CFML construct was a CFIF tag occupying document position (9:15) to (9:19).
The specific sequence of files included or processed is:
C:\Inetpub\wwwroot\member\
What can I do to make this work?????????????
sorry i'm such an idiot about all this, I'm sure it's supposed to be easy, but I must have a synapse missing in my brain....
michelle
ASKER
Ok and not only the above questions and problems, but also what about the fields called New_FieldName and Image_File that you have in the code as well....should these be something else as well?
New_fieldName is a variable used - so u dont need to change ne-thign there !
image_file - is used incase ur deleting a previous file & reuploading a new one ... so that wld be ur previous file name - used to search teh DB & delete the earlier record.
see its logical schema that i ahve given u - ur almost there .. just make some modifications as per ur forms & thigns shld be RIGHT !
K'Rgds
Anand
PS: u output the next error here - so its easy for me to understand where exactly ur getting stuck [with line no & value's]
image_file - is used incase ur deleting a previous file & reuploading a new one ... so that wld be ur previous file name - used to search teh DB & delete the earlier record.
see its logical schema that i ahve given u - ur almost there .. just make some modifications as per ur forms & thigns shld be RIGHT !
K'Rgds
Anand
PS: u output the next error here - so its easy for me to understand where exactly ur getting stuck [with line no & value's]
ASKER
Anand,
I sent you an email regarding whether or not you could go on my server and solve the problem for me? I can pay some if you'd like...let me know asap
Michelle
I sent you an email regarding whether or not you could go on my server and solve the problem for me? I can pay some if you'd like...let me know asap
Michelle
ok - i'll take a look at this & reply back to u
can i have access to the cfm files - so if needed i can modify them stratit away & lessen ur worries :)
let me know
K'Rgds
Anand
can i have access to the cfm files - so if needed i can modify them stratit away & lessen ur worries :)
let me know
K'Rgds
Anand
ASKER
ok i emailed you at the yahoo and hotmail addresses, please check when you can, thanks a lot i really appreciate this!!
Michelle
Michelle
i replied back at ur email add
chk ur mail
K'Rgds
Anand
chk ur mail
K'Rgds
Anand
Hi,
well looks like uve totally mixed up the 2 pages
i will be pasting the code here ... u'll ahve 2 files with one with form elements & other with the code to read them
K'Rgds
Anand
PS : i am pasting the code here [wld also email it to u] - so it helps others reading this thread someday
well looks like uve totally mixed up the 2 pages
i will be pasting the code here ... u'll ahve 2 files with one with form elements & other with the code to read them
K'Rgds
Anand
PS : i am pasting the code here [wld also email it to u] - so it helps others reading this thread someday
<!--- ========================== ========== ========== ========== ========== ========== ========== ========== ========== --->
<!--- File 1 - having ur form --->
<FORM NAME="frm" action="viewfile.cfm" enctype="multipart/form-da ta" method="post">
<CFOUTPUT QUERY="GETINFO">
<INPUT type="hidden" name="AccountNumber" value="#session.AccountNum ber#">
<P align="center"><B><FONT size="2">Other Medical Records:</FONT></B></P>
<P align="center"><FONT size="2">
<INPUT type="file" size="20" name="New_FieldName#Curren tRow#"><BR ><!--- create diff names for each record --->
<INPUT type="submit" value="Store"></FONT></P>
</CFOUTPUT>
<INPUT TYPE="hidden" NAME="RunCount" VALUE="#GETINFO.RecordCoun t#"><!--- used on next page for reading the form values --->
</FORM><!--- have form tags outside output so theres only one form with multiple elemets in it --->
<!--- ========================== ========== ========== ========== ========== ========== ========== ========== ========== --->
<!--- file 2 having ur upload code --->
<CFSET FilePath = "C:\Clients\Anandkp\images \"><!--- directory path where u want to store the images --->
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i #') AND TRIM(Evaluate('New_FieldNa me#i#')) NEQ ''><!--- Upload --->
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i #" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH>
</CFCATCH>
</CFTRY>
</CFIF>
</CFLOOP>
<!--- File 1 - having ur form --->
<FORM NAME="frm" action="viewfile.cfm" enctype="multipart/form-da
<CFOUTPUT QUERY="GETINFO">
<INPUT type="hidden" name="AccountNumber" value="#session.AccountNum
<P align="center"><B><FONT size="2">Other Medical Records:</FONT></B></P>
<P align="center"><FONT size="2">
<INPUT type="file" size="20" name="New_FieldName#Curren
<INPUT type="submit" value="Store"></FONT></P>
</CFOUTPUT>
<INPUT TYPE="hidden" NAME="RunCount" VALUE="#GETINFO.RecordCoun
</FORM><!--- have form tags outside output so theres only one form with multiple elemets in it --->
<!--- ==========================
<!--- file 2 having ur upload code --->
<CFSET FilePath = "C:\Clients\Anandkp\images
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH>
</CFCATCH>
</CFTRY>
</CFIF>
</CFLOOP>
Did that help ???
let me know !!!
K'Rgds
Anand
let me know !!!
K'Rgds
Anand
ASKER
Now nothing appears on the viewfile.cfm page. When I check the server, there is no file like the one I tried to upload. The efile (form) is just like above, the viewfile is like this:
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFSET FilePath = "C:\inetpub\wwwroot\member \#AccountN umber#"><! --- directory path where u want to store the images --->
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i #') AND TRIM(Evaluate('New_FieldNa me#i#')) NEQ ''><!--- Upload --->
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i #" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH>
</CFCATCH>
</CFTRY>
</CFIF>
</CFLOOP>
</cfif>
I am obviously still doing something wrong here, I just don't know what. Help!!!!!!
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFSET FilePath = "C:\inetpub\wwwroot\member
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH>
</CFCATCH>
</CFTRY>
</CFIF>
</CFLOOP>
</cfif>
I am obviously still doing something wrong here, I just don't know what. Help!!!!!!
Hi Michelle,
2 things - very important
whenever u upload a file -always chk if the directory where ur trying to upload EXISTS
Also have a trailing slash at the end of the filepath
try the code below !
<CFIF isDefined("Session.Account Number") is NOT TRUE>
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFSET FilePath = "C:\inetpub\wwwroot\member \#AccountN umber#"><! --- directory path where u want to store the images --->
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i #') AND TRIM(Evaluate('New_FieldNa me#i#')) NEQ ''> <!--- Upload --->
<CFTRY>
<CFIF Not DirectoryExists('C:\inetpu b\wwwroot\ member\#Ac countNumbe r#\')>
<CFDIRECTORY ACTION="CREATE" DIRECTORY="C:\inetpub\wwwr oot\member \#AccountN umber#\">
</CFIF>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i #" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH></CFCATCH></CFTRY >
</CFIF>
</CFLOOP>
</CFIF>
remember u didnt c ne-thing bcos its encapsulated inb/w try/catch blcck
if u want to debug - open it up & then c what it gives
K'Rgds
Anand
2 things - very important
whenever u upload a file -always chk if the directory where ur trying to upload EXISTS
Also have a trailing slash at the end of the filepath
try the code below !
<CFIF isDefined("Session.Account
<CFLOCATION url="logon.cfm">
<CFELSE>
<CFSET FilePath = "C:\inetpub\wwwroot\member
<CFLOOP INDEX="i" FROM="1" TO="#RunCount#">
<CFIF ISDEFINED('New_FieldName#i
<CFTRY>
<CFIF Not DirectoryExists('C:\inetpu
<CFDIRECTORY ACTION="CREATE" DIRECTORY="C:\inetpub\wwwr
</CFIF>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName#i
<CFQUERY name="Upd_Table" DATASOURCE="#medlife#" DBTYPE="ODBC" USERNAME="#UserName#" PASSWORD="#Password#">
Update medlife set filename = '#FILE.SERVERFILE#'
</CFQUERY>
<CFCATCH></CFCATCH></CFTRY
</CFIF>
</CFLOOP>
</CFIF>
remember u didnt c ne-thing bcos its encapsulated inb/w try/catch blcck
if u want to debug - open it up & then c what it gives
K'Rgds
Anand
ASKER
Ok, I got the info to appear in the server...but how do I make it appear in a categorized list, that is hyperlinked to the actual documents, pictures, etc.?
We are <-> this close! Thanks so much!
We are <-> this close! Thanks so much!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much Anand! I really appreciate it!
Michelle
Michelle
anand, could you post the answer so it will show up if someone else has this problem?
while viewing the files - usign the DB & code - make sure u allow users to see only those files that r uplaoded by them.
the rename/delete& adding files can be done using the following code :
<CFIF ISDEFINED('New_FieldName')
<CFIF ACT EQ "EDIT"><!--- Del existing one - only incase of edit mode !!! --->
<CFQUERY NAME="Del_Img" DATASOURCE="#IWD_DSN#" DBTYPE="ODBC" USERNAME="#IWD_USERNAME#" PASSWORD="#IWD_PASSWORD#">
Select New_FieldName from TableName where New_FieldName = #Image_FieldName#
</CFQUERY>
<CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del
<CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.N
</CFIF>
<CFSET New_FieldName = ""><!--- Since image is deleted - set it to blank --->
</CFIF>
<CFTRY>
<CFFILE ACTION="UPLOAD" FILEFIELD="New_FieldName" DESTINATION="#FilePath#" NAMECONFLICT="MakeUnique">
<CFIF ISDEFINED('Rename')><!--- Rename ! --->
<CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'
<CFFILE ACTION="RENAME" SOURCE="#FilePath##FILE.SE
<CFSET New_FieldName = "#NewFileName#.#FILEEXT#">
<CFELSE><!--- keep original name as it is --->
<CFSET New_FieldName = #FILE.SERVERFILE#>
</CFIF>
<CFCATCH>
</CFCATCH>
</CFTRY>
<CFQUERY name="Upd_Table">
Update Table set ImageName = '#New_FieldName#'
</CFQUERY>
<CFELSE>
<!--- Keep the Image As It Is ! --->
<!--- Dont do ne-thing here --->
</CFIF>
K'Rgds
Anand