|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#16
|
|||
|
|||
|
Yes,
Here is the page outline. The first page name insert.cfm <cfform action="insert_processing.cfm" method="post" enctype="multipart/form-data"> username <cfinput type="text" name="username"> image <cfoutput><input type="file" name="image"></cfoutput> ------The reason I used cfoutput is so that there is no error message later on in the next page--- <input type="submit" value="insert"> </cfform> The next page: insert_processing.cfm <cfquery datasource="datasource_name"> insert into user values(#form.username#, #form.image#) </cfquery> <cfquery datasource="datasource_name" name="show"> select * from user where userid = #form.userid# </cfquery> <cfoutput query="show">#username#</cfoutput> Your photo: <cfif isdefined("form.image") and form.image is not ""> <cffile action="upload" destination="path of server_folder" fileField="form.image"> <cfoutput> You uploaded #cffile.ClientFileName#.#cffile.ClientFileExt# successfully to #cffile.ServerDirectory#. </cfoutput> <cfquery name="getimage_name" datasource="datasource_name"> SELECT image FROM user WHERE userid = #form.userid# </cfquery> Here is your image <img src="images/#getimage_name.image#"> <cfelse> </cfif><br> That is it. Please let me know where I got wrong. Thanks so much for helping me!!! |
|
#17
|
|||
|
|||
|
Hi Sun -
OK, here's a few things I see... however, I can't tell if this is the real code from your page, or if you've abridged for the sake of the post: <cfquery datasource="datasource_name"> insert into user values(#form.username#, #form.image#) </cfquery> is not a valid query. As far as I know, you *always* need to specify which fieldname you are inserting to. Also, you need single quotes around string values. Next, where is FORM.userid being set? I don't see an input on the insert.cfm, hidden or otherwise, and you reference it in two separate places on the processing page. Also, <cffile action="upload" destination="path of server_folder" fileField="form.image"> The destination parameter here needs to be a valid absolute path... Is this just placeholder text for the sake of this post? Next, <cfoutput> You uploaded #cffile.ClientFileName#.#cffile.ClientFileExt# successfully to #cffile.ServerDirectory#. </cfoutput> Is the above output correct when you run the page? Finally, are you getting any errors when you run the page? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > open window to select a picture file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|