0

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.

2
Contributors
12
Replies
14
Views
4 Years
Discussion Span
Last Post by arrgh
0

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.

0

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#

0

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

0

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.

0

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
0

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.

0

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

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.

0

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

1

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.