WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. pmagony
    Member
    Posted 2 years ago #

    Hello,

    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.

    Thanks!

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. pmagony
    Member
    Posted 2 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
    Member
    Posted 2 years ago #

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

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

  5. AsraiLight
    Member
    Posted 1 year 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

About this Topic