Contact Form 7
Replace Same Name File After Upload (5 posts)

  1. pmagony
    Posted 4 years ago #


    This is an issue that expands on this thread: http://wordpress.org/support/topic/plugin-contact-form-7-leave-file-upload-on-server?replies=9

    Which I opened months back in an attempt to allow the "upload" file function to "leave" the field on the server. I've been able to successfully achieve this, however, I am running into a new issue.

    When a user uploads a file with the same name, in hopes to replace the old file with the new one, the script simply uploads it to the server, BUT it renames it. For example:

    file.pdf (old that needs to be replaced)
    file1.pdf (latest uploaded file gets renamed)

    In my search to resolve the issue on my own, I've come across threads and suggestions that the folders need to have write permission and that the files need to be owned by the same user. I can successfully confirm both of these are correct.

    The folder is 777, the file is 777. What I do not know is who the owner is when the file upload function gets executed.

    See, I have an upload page which a user accesses, then uploads the file. The file is stored on the server has the same ownership with the same owner writes, but the file still gets renamed. For the record, the file being uploaded has the exact same name as the file on the server.

    If anyone can help me "replace" the existing file without renaming it, I would be very grateful.



  2. Takayuki Miyoshi
    Plugin Author

    Posted 4 years ago #

    Customizing to leave uploaded files on your server makes a big security hole. I'd never suggest it.

  3. pmagony
    Posted 4 years ago #

    Not unless you know how to lock it down. But that's not what the question is regarding. Thanks for your input.

  4. pmagony
    Posted 4 years ago #

    Line 170, of modules/file.php needs to be commented out

    $filename = wp_unique_filename( $uploads_dir, $filename );

  5. AsraiLight
    Posted 3 years ago #

    Thanks very much for this, it is quite helpful. Can you share how you are locking it down to prevent a breach in security?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic