?
Solved

CFFILE UPLOAD Subscriber Issues

Posted on 2003-03-19
32
Medium Priority
?
268 Views
Last Modified: 2013-12-24
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.AccountNumber") 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
0
Comment
Question by:mflagstad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 16
  • 13
  • 3
32 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 8171631
u can provide multiple upload options to users. if they choose to upload [A,B,C,D ...] - they all get uploaded to the respective folders on the server

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') AND TRIM(New_FieldName) NEQ ''><!--- Upload --->
     <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_Img.New_FieldName#')>
               <CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.New_FieldName#">
          </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.SERVERFILE#" DESTINATION="#FilePath##NewFileName#.#FILEEXT#">
            <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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8173647
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.AccountNumber") is NOT TRUE>
     <CFLOCATION url="logon.cfm">
<CFELSE>

<cfquery name="getinfo" datasource="mydsn">
     Select * from med
     WHERE AccountNumber='#session.AccountNumber#'
     </cfquery>
<CFOUTPUT QUERY = "GETINFO">
    <FORM action = "file1.cfm" enctype="multipart/form-data" 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></FORM></cfoutput>

  <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\11145779060\) 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          
0
 
LVL 10

Expert Comment

by:substand
ID: 8174648
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>


0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 1

Author Comment

by:mflagstad
ID: 8177857
I have no idea what you mean...any sample code?
thanks, Michelle
0
 
LVL 10

Expert Comment

by:substand
ID: 8177920
<CFDIRECTORY ACTION="create"
    DIRECTORY="c:\inetpub\applicationname\users\"
    NEWDIRECTORY="#userID#">

0
 
LVL 1

Author Comment

by:mflagstad
ID: 8177942
I have no idea what you mean...any sample code?
thanks, Michelle
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8178545
I have no idea what you mean...any sample code?
thanks, Michelle
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8178553
So do you mean like this?
efile upload page:

<CFIF isDefined("Session.AccountNumber") is NOT TRUE>
    <CFLOCATION url="logon.cfm">
<CFELSE>
<cftry>

<cfcatch>
<CFDIRECTORY ACTION="create"
   DIRECTORY="c:\inetpub\wwwroot\users\"
   NEWDIRECTORY="#AccountNumber#">



<cfquery name="getinfo" datasource="mydsn">
    Select * from med
    WHERE AccountNumber='#session.AccountNumber#'
    </cfquery>
<CFOUTPUT QUERY = "GETINFO">
   <FORM action = "viewfile.cfm" enctype="multipart/form-data" 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></FORM></cfoutput>

 <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.AccountNumber") 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="#AccountNumber#">
              Select New_File from medlife where New_File = #Image_File#
         </CFQUERY>
         <CFIF DEL_IMG.RECORDCOUNT GT 0 AND FILEEXISTS('#FILEPATH##Del_Img.New_File#')>
              <CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.New_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.SERVERFILE#" DESTINATION="#FilePath##NewFileName#.#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
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8178937
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:\inetpub\wwwroot\users\#AccountNumber#')>
    <CFDIRECTORY ACTION="create"
      DIRECTORY="c:\inetpub\wwwroot\users\"
      NEWDIRECTORY="#AccountNumber#">
</CFIF>

let me know ...

K'Rgds
Anand
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8180900
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,CONNECTSTRING,DATASOURCE,DBNAME,DBPOOL,DBSERVER,DEBUG,MAXROWS,NAME,PASSWORD,PROVIDER,PROVIDERDSN,SQL,TIMEOUT,USERNAME'.
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDWITHIN,CONNECTSTRING,DBNAME,DBPOOL,DBSERVER,DBTYPE,DEBUG,MAXROWS,NAME,PASSWORD,PROVIDER,PROVIDERDSN,SQL,TIMEOUT,USERNAME'.
Required attributes: 'DATASOURCE'. Optional attributes: 'BLOCKFACTOR,CACHEDAFTER,CONNECTSTRING,DBNAME,DBPOOL,DBSERVER,DBTYPE,DEBUG,MAXROWS,NAME,PASSWORD,PROVIDER,PROVIDERDSN,SQL,TIMEOUT,USERNAME'.
Other possible combinations are
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDAFTER,DEBUG,MAXROWS,SQL,TIMEOUT'.
Required attributes: 'DBTYPE,NAME'. Optional attributes: 'CACHEDWITHIN,DEBUG,MAXROWS,SQL,TIMEOUT'.
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.AccountNumber") 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_File#')>
              <CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.New_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.SERVERFILE#" DESTINATION="#FilePath##NewFileName#.#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?
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8192930
hi replace the code with this

<CFIF isDefined("Session.AccountNumber") 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_File#')>
                    <CFFILE ACTION="DELETE" FILE="#FilePath##Del_Img.New_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.SERVERFILE#" DESTINATION="#FilePath##NewFileName#.#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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8194873
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...
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8195220
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...
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8200414
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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8203520
OK, what variables do I need in here?
the dsn is medlife
the path is c:\inetpub\wwwroot\fpdb\medlife.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
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8208191
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\uploaddir\" [this cld be whatever u have decided for ur project]

rest it shld work fine

K'Rgds
Anand
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8210142
Still not working and I am going crazy....

here is the form page:

<CFIF isDefined("Session.AccountNumber") is NOT TRUE>
    <CFLOCATION url="logon.cfm">
<CFELSE>

 




<cfquery name="getinfo" datasource="medlife">
    Select * from med
    WHERE AccountNumber='#session.AccountNumber#'
    </cfquery>
   
     
   
<CFOUTPUT QUERY = "GETINFO">

 
   <FORM action = "viewfile.cfm" enctype="multipart/form-data" 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></FORM></cfoutput>

 <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.AccountNumber") 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.filename#">
              </CFIF>
              <CFSET filename = ""><!--- Since image is deleted - set it to blank --->
         </CFIF>
         <CFTRY>
         <CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#AccountNumber#" NAMECONFLICT="MakeUnique">
         <CFIF ISDEFINED('Rename')>               <!--- Rename ! --->
              <CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'.')>
              <CFFILE ACTION="RENAME" SOURCE="#AccountNumber##FILE.SERVERFILE#" DESTINATION="#AccountNumber##filenameName#.#FILEEXT#">
              <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\#AccountNumber#?
That would be the physical path...


except, i just tried that:

<CFIF isDefined("Session.AccountNumber") 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\wwwroot\AccountNumber##Del_Img.filename#')>
                   <CFFILE ACTION="DELETE" FILE="#c:\inetpub\wwwroot\AccountNumber##Del_Img.filename#">
              </CFIF>
              <CFSET filename = ""><!--- Since image is deleted - set it to blank --->
         </CFIF>
         <CFTRY>
         <CFFILE ACTION="UPLOAD" FILEFIELD="filename" DESTINATION="#c:\inetpub\wwwroot\AccountNumber#" NAMECONFLICT="MakeUnique">
         <CFIF ISDEFINED('Rename')>               <!--- Rename ! --->
              <CFSET FILEEXT = LISTLAST(FILE.SERVERFILE,'.')>
              <CFFILE ACTION="RENAME" SOURCE="#c:\inetpub\wwwroot\AccountNumber##FILE.SERVERFILE#" DESTINATION="#c:\inetpub\wwwroot\AccountNumber##filenameName#.#FILEEXT#">
              <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\viewfile.cfm      

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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8210226
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?
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8210323
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]

0
 
LVL 1

Author Comment

by:mflagstad
ID: 8215120
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
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8215630
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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8217280
ok i emailed you at the yahoo and hotmail addresses, please check when you can, thanks a lot i really appreciate this!!
Michelle
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8217403
i replied back at ur email add
chk ur mail

K'Rgds
Anand
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8243406
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
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8244268
<!--- ========================================================================================================== --->
<!--- File 1 - having ur form --->

<FORM NAME="frm" action="viewfile.cfm" enctype="multipart/form-data" method="post">
    <CFOUTPUT QUERY="GETINFO">  
        <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="New_FieldName#CurrentRow#"><BR><!--- create diff names for each record --->
        <INPUT type="submit" value="Store"></FONT></P>  
    </CFOUTPUT>
    <INPUT TYPE="hidden" NAME="RunCount" VALUE="#GETINFO.RecordCount#"><!--- 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_FieldName#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>
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8274598
Did that help ???
let me know !!!

K'Rgds
Anand
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8275021
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.AccountNumber") is NOT TRUE>
     <CFLOCATION url="logon.cfm">
<CFELSE>
<CFSET FilePath = "C:\inetpub\wwwroot\member\#AccountNumber#"><!--- 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_FieldName#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!!!!!!
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8289566
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.AccountNumber") is NOT TRUE>
     <CFLOCATION url="logon.cfm">
<CFELSE>
     <CFSET FilePath = "C:\inetpub\wwwroot\member\#AccountNumber#"><!--- 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_FieldName#i#')) NEQ ''>               <!--- Upload --->
               <CFTRY>
               <CFIF Not DirectoryExists('C:\inetpub\wwwroot\member\#AccountNumber#\')>
                    <CFDIRECTORY ACTION="CREATE" DIRECTORY="C:\inetpub\wwwroot\member\#AccountNumber#\">
               </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
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8291221
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!
0
 
LVL 17

Accepted Solution

by:
anandkp earned 760 total points
ID: 8340070
i had send a email to u on this - did u get it ?
it had the answere !

let me know if its solved !

Thanx
Anand
0
 
LVL 1

Author Comment

by:mflagstad
ID: 8340406
Thanks so much Anand! I really appreciate it!
Michelle
0
 
LVL 10

Expert Comment

by:substand
ID: 8344970
anand, could you post the answer so it will show up if someone else has this problem?
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question