Professional Web Applications Themes

Image Upload - Coldfusion - Advanced Techniques

I am having problem uploading an image. Here is what I have: Form part: <input type="file" name="featimage" size="50" /> Upload part: <cffile action="upload" filefield="featimage" destination= "C:\webroot\kate\images\" accept="image/*" nameconflict="MakeUnique"> <cfset uploadedfile = "c:\webroot\kate\images\#cffile.serverfile#"> It will not upload. I check c:\webroot\kate\images\ and nothing is there. Any suggestions....

  1. #1

    Default Image Upload

    I am having problem uploading an image. Here is what I have:

    Form part:
    <input type="file" name="featimage" size="50" />

    Upload part:
    <cffile action="upload" filefield="featimage" destination=
    "C:\webroot\kate\images\" accept="image/*" nameconflict="MakeUnique">
    <cfset uploadedfile = "c:\webroot\kate\images\#cffile.serverfile#">

    It will not upload. I check c:\webroot\kate\images\ and nothing is there.

    Any suggestions.

    Seth Buntin Guest

  2. #2

    Default Re: Image Upload

    Have you set the form enctype to "multipart/form-data"?

    Trygve
    Trygve Guest

  3. #3

    Default Re: Image Upload

    I do have enctype="multipart/form-data" in my form tag.
    Seth Buntin Guest

  4. #4

    Default IMAGE UPLOAD

    i am using the code below, to upload an image to my folder aswell as the
    "myfilename" to my table.

    this works without a where clause and puts the file name into every record,
    but when i put the where clause in i get the right record but with the file
    name of C:\CFusionMX7\runtime\servers\coldfusion\SERVER-IN

    any ideas

    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#myFileName#'
    WHERE FacilityName='#FacilityName#'
    </CFQUERY>

    Craig77 Guest

  5. #5

    Default Re: IMAGE UPLOAD

    If you're using CFFILE, after the upload, use one of the available CFFILE
    variables. For example:

    <CFFILE action="upload" ...... >
    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#CFFILE.serverFile#'
    WHERE FacilityName='#FacilityName#'
    </CFQUERY>

    A full list of the variables available can be found in livedocs
    http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p35.htm

    mxstu Guest

  6. #6

    Default Re: IMAGE UPLOAD

    i am already using this code attached

    <CFFILE ACTION="UPLOAD"
    DESTINATION="c:\inetpub\wwwroot\CompanyImages\"
    FILEFIELD="WebSite_CompanyLogo"
    ACCEPT="image/pjpeg, image/jpeg, image/jpg, image/jpe_, image/pjpeg"
    nameConflict = "MakeUnique">

    <CFSET myFileName = cffile.serverfile>

    <CFOUTPUT>Name of file uploaded to server: #myFileName#</CFOUTPUT>

    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#myFileName#'
    WHERE FacilityName='#FacilityName#'
    </CFQUERY>

    Craig77 Guest

  7. #7

    Default Re: IMAGE UPLOAD

    If that is the exact code you're using, it seems to work fine for me.
    "C:\CFusionMX7\runtime\servers\coldfusion\SERV ER-IN" is a temporary file name.
    You would probably see that value if you tried to reference the form field
    directly instead of using the CFFILE variables like this:
    #form.WebSite_CompanyLogo#. Are you sure your UPDATE statement is actually
    succeeding?



    mxstu Guest

  8. #8

    Default Re: IMAGE UPLOAD

    yes if i take out the where clause it puts the correct filename in, but obviously in all the records, i have tried the variable you surgested but wouldnt work
    Craig77 Guest

  9. #9

    Default Re: IMAGE UPLOAD

    >yes if i take out the where clause it puts the correct filename in, but
    obviously in all the records, 

    What do you mean doesn't work? Also, does your table actually contain a
    record matching the #FacilityName#?

    WHERE FacilityName='#FacilityName#'


    If you turn on

    mxstu Guest

  10. #10

    Default Re: IMAGE UPLOAD

    ok this now works, i have one more small problem, this is ok for 1 image upload
    i have ten on the same from
    so do i have to duplicate the code for each one or can i use commas to
    seperate them?

    <CFFILE ACTION="UPLOAD"
    DESTINATION="c:\inetpub\wwwroot\CompanyImages\"
    FILEFIELD="WebSite_CompanyLogo"
    ACCEPT="image/pjpeg, image/jpeg, image/jpg, image/jpe_, image/pjpeg"
    nameConflict = "MakeUnique">

    <CFSET myFileName = cffile.serverfile>

    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#myFileName#'
    WHERE FacilityName='#FacilityName#'
    </CFQUERY>

    Craig77 Guest

  11. #11

    Default Re: IMAGE UPLOAD

    So what was the problem?

    Are uploading files for 10 different facilities in the same form?
    mxstu Guest

  12. #12

    Default Re: IMAGE UPLOAD

    no 10 files for the same facility

    so do i change the following with commas? i.e.

    FILEFIELD="WebSite_CompanyLogo", image2, image3, image4

    <CFSET myFileName = cffile.serverfile>

    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#myFileName#',
    image1= '#myFileName#',
    image2= '#myFileName#',
    image3= '#myFileName#',
    WHERE FacilityName='#FacilityName#'
    </CFQUERY>


    Craig77 Guest

Similar Threads

  1. Upload an image
    By suburbsalliance in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: June 13th, 06:51 AM
  2. Image upload/download
    By Ken D. Nelson in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: April 6th, 04:12 PM
  3. image upload problem
    By navee in forum Macromedia ColdFusion
    Replies: 0
    Last Post: March 28th, 06:04 PM
  4. Image upload to FM Web companion?
    By Richard J in forum FileMaker
    Replies: 1
    Last Post: August 28th, 04:01 AM
  5. How to upload an image in asp.net
    By Varun_789 in forum ASP.NET General
    Replies: 4
    Last Post: July 12th, 11:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139