Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
ashbuckles_com #1
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
-
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... -
CFFILE - Upload on Unix/Solaris not working..
after removing MODE and ACCEPT This still does not work: <CFFILE ACTION="UPLOAD" FILEFIELD="Form.FiletoUpload"^M... -
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... -
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... -
CFFILE...nameconflict="makeunique"
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?event=view&id=KC.tn_16... -
ashbuckles_com #2
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



Reply With Quote

