WordPress.org

Forums

[resolved] [Plugin: Contact Form 7] Checkbox to Delete from Server (3 posts)

  1. pmagony
    Member
    Posted 3 years ago #

    Hello Amigos,

    I've successfully created a WPCF7 Upload file page which allows my user to upload a file. I'm running into an issue where I need to give the user the option to delete the current file that is on the server, during the upload of the current file.

    The file needs to remain the same "name" on the server - it cannot change as we have a direct link that references it all the time. If we do not delete the file, then the upload script sequentially numbers the file when it detects the same file exists.

    file.txt
    file1.txt
    file2.txt
    and so on...

    I would like to put a checkbox that "deletes" the current file, while uploading the latest one.

    Or, negate the script from renaming the file and simply OVERWRITE the current one on the server during upload.

    Any help is greatly appreciated!

  2. pmagony
    Member
    Posted 3 years ago #

    Resolved.

    In /contact-form-7/modules/file.php line 174:

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

    Needs to be commented out. I also changed the CHMOD of the file to 0644 at line 185:

    @chmod( $new_file, 0644 );

  3. pmagony
    Member
    Posted 3 years ago #

    I should mention that I did not add a "checkbox". I simply tweaked the existing scripts functionality so that it's automatic on the upload.

Topic Closed

This topic has been closed to new replies.

About this Topic