cffile upload - makeunique not working

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default cffile upload - makeunique not working

    My application allows clients to upload images to their account. The process of
    my application is: upload file from form, set to variable myFile, passed off to
    the aspimage component (where I open the image, resize, crop, and save the file
    with a new name), my application then deletes the original file.

    My problem arises when 2 clients upload an image with the same name. The image
    is uploaded, but the "MAKEUNIQUE" feature does not always work thereby allowing
    the new image to overwrite the old image and the client who originally uploaded
    the file now has someone elses image in their account.

    Why does "MAKEUNIQUE" work sometimes and not others?

    <!--- Set upload directory --->
    <cfset path = "mypath">

    <!--- Upload image --->
    <cffile action="upload" destination="#path#" nameconflict="MAKEUNIQUE"
    filefield="fileToUpload" accept="image/gif, image/jpg, image/pjpeg, image/jpeg">

    <!--- Set myFile to the name of the uploaded file --->
    <cfset myFile = #cffile.serverFile#>

    <!--- Make sizing and cropping changes --->
    <!--- Be sure to reference the photo to the client and ad ID's --->
    <cfinclude template="aspimage.cfm">

    <!--- Insert database record --->
    <cfquery name="insertPhoto" datasource="myodbc">
    insert into clientphotos (clientID, sicName, path, name, description,
    dateCreated)
    values (#session.clientID#, <cfif galleryQualify is
    1>'#urlDecode(sic)#'<cfelse>NULL</cfif>, '/clientphotos', '#myFile#', <cfif
    isdefined("description")>'#reReplace(description, chr(13) & chr(10), ' ',
    'all')#'<cfelse>NULL</cfif>, #createodbcdatetime(now())#)
    </cfquery>

    ashbuckles_com Guest

  2. Similar Questions and Discussions

    1. CFFILE Upload Suddenly Not Working
      Originally this worked, and now it processes it and puts the correct url in the database, but it just doesn't upload the image. Any help why it...
    2. CFFILE - Upload on Unix/Solaris not working..
      after removing MODE and ACCEPT This still does not work: <CFFILE ACTION="UPLOAD" FILEFIELD="Form.FiletoUpload"^M...
    3. CFFILE Upload
      Hi, i would build an upload form for pictures. how can i limit the upload to the size attributes (width & height) of the picture? the user should...
    4. Get an error when trying to upload a file on CF 4.5using makeunique.
      I've recently taken over an old application that uses ColdFusion 4.5. I'm experiencing a problem with pages that use the CFFILE tag with attribute...
    5. CFFILE...nameconflict="makeunique"
      http://www.macromedia.com/cfusion/knowledgebase/index.cfm?event=view&id=KC.tn_16...
  3. #2

    Default Re: cffile upload - makeunique not working

    Ah ha.

    Here is why it seems to work inconsistently -- at least in my case.

    I upload a file, make changes, save as a new file name, and delete the
    original. Well, my problem lies with deleting the original filename because
    then when the next person tries to upload a file with the same name, my
    application accepts it because the "original" filename is not there to compare
    to. It has been renamed. Then when the new file is accepted, processed, and
    saved to the new name, it overwrites that original files "new" name.

    I hope this makes sense, and that it can help you.

    ashbuckles_com Guest

Posting Permissions

  • You may not post new threads
  • You may 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