Solved

Why is my user image cffile uploads not working?

Posted on 2008-10-25
3
442 Views
Last Modified: 2013-12-24
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

0
Comment
Question by:Janrow
  • 2
3 Comments
 
LVL 63

Expert Comment

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

Open in new window

0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 22804938
Also add jpeg to mime types:
accept="image/jpg,image/jpeg,image/gif">

Open in new window

0
 

Author Closing Comment

by:Janrow
ID: 31510002
That seems to have done it! Thanks!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question