EasyCFM.COM ColdFusion Forums / Coding Help! / a problem to upload image

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: a problem to upload image

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

aki
02-11-2010 @ 7:27 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Feb 2010

hi, i'm having a problem to use upload image coding..for your information i'v tried to run "random image" tutorial in this website but i could not run the "upload_action.cfm" coding..


--form.cfm--
<form action="upload_action.cfm" method="POST"  name="contact" onsubmit='return checkForm();'>
<div>
<TABLE BORDER="0" bgcolor="#ffffff">
   <TR>
     <TD>Browse for Image File:</TD>
     <TD><input name="picture" size="53" type="file" ></TD>
   <tr>
     <td>Type in Description:</TD>
     <TD><textarea name="descrip" rows="7" cols="50"></textarea></TD>
   <TR>
     <TD>Type in hyperlink:</TD>
     <TD><input type="text" name="link" size="66"></TD>
   </TR>
   <TR>
     <TD COLSPAN="2"><input type="Submit" value="Insert"></td>
   </tr>
  </TABLE>
</div>
</form>
<BR><BR>
<cfinclude template ="list.cfm">




--upload_action.cfm--
<cfif picture NEQ '>
    <CFFILE ACTION="upload"
                FILEFIELD="picture"
                DESTINATION="C:\Inetpub\wwwroot\randomimage\image\" (this is my destination)
                NAMECONFLICT="MAKEUNIQUE">
    <cfset upload= #file.serverfile#>
    <cfoutput>
        #serverFile# successfully added. Size of the uploaded file:
        #Numberformat(Evaluate(File.FileSize/1024))# KB.</cfoutput>
</cfif>

the error message said that the variable "picture" was undefined...if anyone know why is this happen, can you help me

tgruen
02-12-2010 @ 12:12 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 59
Joined: Aug 2006

Try modifying your FORM statement...

<cfform name="contact" method="post" action="upload_action.cfm" enctype="multipart/form-data">

Tony

donboe
02-14-2010 @ 8:58 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 474
Joined: Nov 2004

<cfif picture NEQ '>

should be

<cfif Form.picture NEQ '>

The action takes place on another page, so you should add the variablale scope Form

aki
02-16-2010 @ 5:54 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Feb 2010

tony :thank you tony..your solution very helpful..is it really related to the attributes/syntax order like name, action and method? anyway, thank you very much for your help.

donboe: thank you for your attention. actually before I posted this problem, I already tried with Form.picture but it still error..then I tried mr.tony solution then the problem was solved...but I really appreciate ur message thank you..


Website Designed and Developed by Pablo Varando.