Skip to main content
Inspiring
February 14, 2007
Question

CFFILE Overwrite

  • February 14, 2007
  • 10 replies
  • 1791 views
I've got a page where someone can upload a photo. If they upload and then
decide they'd rather upload a different picture to replace it, they can do
that. But for some reason, the new file is not replacing the old one, and is
not showing up on the server at all. The old file remains. Here's the code
I'm using. Any ideas?

<cfif IsDefined("Form.File1")>
<cfif #trim(form.File1)# is not "">
<CFFILE ACTION="UPLOAD" FILEFIELD="File1"
DESTINATION="#ExpandPath('../carimages/#URL.SellerID#/')#"
NAMECONFLICT="Overwrite" accept="image/jpg, image/pjpeg, image/jpeg,
image/gif, image/png">

<cfx_imagecr3
load="#ExpandPath('../carimages/#URL.SellerID#/')##CFFILE.ServerFile#"
save="#ExpandPath('../carimages/#URL.SellerID#/image1.jpg')#"
quality="50"
resize="300x300"
dpi="72">

<cffile
action = "delete"
file = "#ExpandPath('../carimages/#URL.SellerID#/')##CFFILE.ServerFile#">


<cfx_imagecr3 load="#ExpandPath('../carimages/#URL.SellerID#/image1.jpg')#"
save="#ExpandPath('../carimages/#URL.SellerID#/image1_thumbnail.jpg')#"
quality="50"
resize="110x110"
dpi="72">


</cfif>


    This topic has been closed for replies.

    10 replies

    Inspiring
    February 15, 2007
    Yep. That worked great. Thanks folks.

    "Bill00" <billgt@this.net> wrote in message
    news:er0krd$61e$1@forums.macromedia.com...
    >I was thinking about that... I'm going to try it and I'll get back to you
    >later (eating a great Valentine's dinner right now...)
    >
    >
    > "Sabaidee" <webforumsuser@macromedia.com> wrote in message
    > news:er0ic2$3hn$1@forums.macromedia.com...
    >> try deleteing an existing file with <cffile> and see if that works. if it
    >> does
    >> not - then it probabbly is the accesspermissions issue. if you can
    >> delete the
    >> file with <cffile action=delete> then... why not delete the existing file
    >> first
    >> and then upload the new one? i know it is not very efficient, but if it
    >> works
    >> while overwriting does not...
    >>
    >
    >


    Inspiring
    February 15, 2007
    I'd have to agree with Azadi, then. See if deleting the file first works.

    Very strange...

    Good luck!

    - Mike
    Inspiring
    February 15, 2007
    In my original upload, it deletes the server file, so deleting works fine.
    But thanks. The directory is a folder within the root of the server.

    "MichaelSJudd" <webforumsuser@macromedia.com> wrote in message
    news:er0gms$1p9$1@forums.macromedia.com...
    > Well, I've seen this on a Windows 2003 Server situation, but you didn't
    > specify, so you can feel free to ignore this! :-)
    >
    > Sounds like rightsissue, i.e. - create rights but not modify or delete.
    >
    > Your program looks good - it should overwrite the image1.jpg file and
    > create
    > the thumbnail.
    >
    > Is the directory under the web root, somewhere else, etc.? You may want to
    > check this.
    >
    > Anyway, you've probably looked at all that already. Just thought I'd lend
    > a
    > hand if I could.
    >
    > - Mike
    >
    >


    Inspiring
    February 15, 2007
    Thanks. It's the latest, with all hotfixes applied.

    "MichaelSJudd" <webforumsuser@macromedia.com> wrote in message
    news:er0kga$5kb$1@forums.macromedia.com...
    > Also, what version of CF are you running?
    >
    > For 7.0.1. there's a hotfix that may apply:
    >
    > http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=f97044e
    >
    > Hope this helps.
    >
    > - Mike
    >


    Inspiring
    February 15, 2007
    I was thinking about that... I'm going to try it and I'll get back to you
    later (eating a great Valentine's dinner right now...)


    "Sabaidee" <webforumsuser@macromedia.com> wrote in message
    news:er0ic2$3hn$1@forums.macromedia.com...
    > try deleteing an existing file with <cffile> and see if that works. if it
    > does
    > not - then it probabbly is the accesspermissions issue. if you can delete
    > the
    > file with <cffile action=delete> then... why not delete the existing file
    > first
    > and then upload the new one? i know it is not very efficient, but if it
    > works
    > while overwriting does not...
    >


    Inspiring
    February 15, 2007
    Also, what version of CF are you running?

    For 7.0.1. there's a hotfix that may apply:

    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=f97044e

    Hope this helps.

    - Mike
    Inspiring
    February 15, 2007
    try deleteing an existing file with <cffile> and see if that works. if it does not - then it probabbly is the accesspermissions issue. if you can delete the file with <cffile action=delete> then... why not delete the existing file first and then upload the new one? i know it is not very efficient, but if it works while overwriting does not...
    Inspiring
    February 15, 2007
    Well, I've seen this on a Windows 2003 Server situation, but you didn't specify, so you can feel free to ignore this! :-)

    Sounds like rightsissue, i.e. - create rights but not modify or delete.

    Your program looks good - it should overwrite the image1.jpg file and create the thumbnail.

    Is the directory under the web root, somewhere else, etc.? You may want to check this.

    Anyway, you've probably looked at all that already. Just thought I'd lend a hand if I could.

    - Mike
    Inspiring
    February 15, 2007
    The first picture is making it fine. When it comes time to replace it, it
    acts like it's uploading the pic, but it doesn't seem to happen. I tried
    Error and MakeUnique, but neither makes a difference. It acts like it
    uploads, and then keeps the old picture on the server.

    "Dinghus" <webforumsuser@macromedia.com> wrote in message
    news:er09k5$nl3$1@forums.macromedia.com...
    > For one thing you have #s all over the place that you don't need them. To
    > troubleshoot, have you tried changing OVERWRITE to either ERROR or
    > MAKEUNIQUE
    > and see what happens? Maybe the file isn't even going up.
    >


    Inspiring
    February 15, 2007
    For one thing you have #s all over the place that you don't need them. To troubleshoot, have you tried changing OVERWRITE to either ERROR or MAKEUNIQUE and see what happens? Maybe the file isn't even going up.