Link to home
Start Free TrialLog in
Avatar of Janrow
JanrowFlag for United States of America

asked on

Why is my user image cffile uploads not working?

I'm using cffile for users to upload images. All seems to go fine when I test but there is never any image in the destination directory, which does exist. No errors.

FYI, I will want to limit the file size and possibly resize the image if too large.

Is there a better way to do this using CF8?
<cfif isdefined("form.iupload") and len(form.myImage)>
 
<cfset myFileName = "">
 
<cffile action="upload"
      destination="C:\ColdFusion8\wwwroot\baker\user_content\"
      nameconflict="makeunique"
      filefield="myImage"
      accept="image/jpg,image/gif">
<cfset myFileName = cffile.serverFile>
      
<cfoutput>
The file Uploaded was #myFileName#
</cfoutput>
 
</cfif> 
 
<form name="iupload" action="send.cfm" method="post" enctype="multipart/form-data">
  Upload image: <input type="file" name="myImage"> <input type="submit" value="Upload">
</form>

Open in new window

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Change your cfif statement to this:
<cfif isdefined("form.myImage") and len(form.myImage)>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Janrow

ASKER

That seems to have done it! Thanks!