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.

4 Years
Discussion Span
Last Post by arrgh

Arrgh... the site ate my response. Anyway, that's a sql UPDATE. The basic syntax is:

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


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.

Edited by arrgh: code formatting


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>"/>

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:


Yes it actually reads:

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

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>

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 ;-)

Edited by arrgh


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

Edited by arrgh: formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.