Hi everyone. I have not done any type of coding in some years and can use some help with a simple yet frustrating task. I am trying to allow registered users to upload a "profile" photo to the server and insert the path into the database. I would like to do this as a "record update" in coldfusion with the session variable MM_Username as the primary key. Can someone please help me with a code sample.

Arrgh... the site ate my response. Anyway, that's a sql UPDATE. The basic syntax is:
http://www.w3schools.com/SQl/sql_update.asp

        <cfquery ...>
            UPDATE TheTableName
            SET    ImagePathColumnName = <cfqueryparam value="#variableWithPath#"
                                                  cfsqltype="(your type here)">
            WHERE  PrimaryKeyColumn = <cfqueryparam value="#variableWithPrimaryKey#"
                                                  cfsqltype="(your type here)">

        </cfquery>

If you need specifics, post your table structure and form code.

Thanks this is what I was able to use:

<cfupdate datasource="pReport"
tablename ="tblAdmins"
formfields="Image, user_name">

my problem was catching the file name which I was able to do by inserting a hidden field with the value of #file.serverfile#

Ok, I didn't know that was your issue. Glad you figured it out. Just one thing - #FILE# is deprecated. Use #CFFILE.serverFile# instead.

Thank you very much I will make that change.

One last question if I may, I am using this CFIF statement to display an image if a record exists in the db or to hide it if no record exists.

<cfif rsProfile.Image GT 0>
<img src="<cfoutput>rs.image</cfoutput>"/>
</cfif>

This works perfectly fine in IE and Chrome however in FF it doesn't display the image even if the record does exist.

Aside from missing # signs around your variable, I'm not sure why it doesn't work.

What's the value of #rs.Image#? It should be a valid URL like:

 /mysite/path/to/myImage.png 
 ../images/myImage.png
 myImage.png

Yes it actually reads:

<cfif rsProfile.Image GT 0>
     <img src="<cfoutput>#rsProfile.Image</cfoutput>#"/>
     </cfif>

This one is strange to me since FF is the only browser that I am having an issue with.

The # signs are still off. But I'm guessing it's just a copy paste error, or you'd be getting a syntax error.

Anyway, you didn't answer my question. What's the actual value of #rsProfile.Image#?

The value of rsProfile.Image = <cfoutput>#rsProfile.Image#</cfoutput><br />
<!--- check the length, not the value --->
<cfif len(trim(rsProfile.Image))>
   <cfoutput><img src="#rsProfile.Image#" /> </cfoutput>
</cfif>

Sorry it has taken me so long to reply. I spent the last 3 days trying to figure out what the problem was and it was a very simple simple fix that I am embarassed about. I was using "\" when I needed "/". :(

Thanks for all of your time and help.

It happens. That is why I suggested printing out the value. Don't feel bad, I once spent an hr chasing my tail only to find out the problem was extra white space. Kept thinking I was right about the code, lol. Didn't figure out my mistake until I went character by character.. Lesson learned ;-)

LOL I guess it happens. I thought it was just me.

ROFL .. I wish! Too bad code always does what we tell it to do, instead of what we want it to do ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.