I am trying to copy an image uploaded using Contact Form 7 to the uploads directory but this only produces an empty jpeg file with 0644 permissions even though the dev directory and the uploads directory have 777 permissions while I try to solve the problem.

I have had this particular set-up working, at least with the version of CF7 current in January 2017 but I cannot fathom why the copied images are always 0-byte files.

The files are all correctly uploaded to Contact Form 7/Flamingo's wpcf7_uploads directory, which resides inside the standard uploads directory, so that's not the problem. It's copying them to another directory so I can rename them and display them that isn't happening.

Just to re-iterate, since I can't seem to update via comments, as far as Contact Form 7 is concerned - and its sibling Flamingo plugin, which allows for saving of uploaded info/images as opposed to simply forwarding and then deleting them - both are playing their part excellently, uploading and saving the images, at least once the line


is commented out (/plugins/contact_form-7/includes/submission.php, line 223, in the submit() function. The problem is simply that attempting to copy the files into a custom directory outside of wp-content fails, and produces 0-byte jpeg images.


2 Answers 2


Since i was also looking for some sort of keeping submitted images, i found this simple plugin, which gave me a bit insight: https://wordpress.org/plugins/store-file-uploads-for-contact-form-7/

Also if you read a bit on the mentioned "file-uploading-and-attachment" topic in cf7, you should get the point:

For security reasons, specifying files outside of the wp-content directory for email attachments is not allowed, so place the files in the wp-content or its subdirectory.

I think if you stay within the wp-content dir, your copy-func may have its content.

  • Most excellent point about reading the docuentation. Also will look up this latest tool as the uploading of attachments especiually images is crucial to avoiding using the dreadful wordpress admin backend/doing everything manually.
    – Hektor
    Mar 19, 2022 at 20:53

Use The WordPress UI to Upload Images

When images are copied into a WordPress directory outside of the UI, it won't work because they don't get registered via the database and assigned a permalink.

Use the WordPress UI to upload your images to make sure they become accessible.

As you can see from this image, where I just uploaded an image via cPanel, it does not show in WordPress.

enter image description here

  • Thanks for the pointer Invariant I was hoping to allow users to upload via a custom Contact Form 7 page rather than through the Wordpress UI. But the CF7 and Flamingo plugins allow me to upload to the uploads directory, and everything is recorded in the wpdb->postmeta table, so I can get to it. Do you have any idea how I can update the necessary tables so that the images can be renamed and copied. Perhaps it's because I'm attempting to move them out of the core wp-content folder hierarchy into a non-tandard directory?
    – Hektor
    Oct 1, 2018 at 7:21
  • Not sure if this has a solution for you? Check it out? youtu.be/-RtBrUCSkBk
    – Electron
    Oct 1, 2018 at 7:43
  • And this: contactform7.com/file-uploading-and-attachment
    – Electron
    Oct 1, 2018 at 7:44
  • If my answer was any help, please feel free to upvote :)
    – Electron
    Oct 1, 2018 at 14:14
  • 1
    Apologies, and thanks for the very useful pointer, I will be sure to check out exactly how to fully integrate any images uploaded/produced outside of the wordpress core into the standard UI. And I hadn't yet upvoted your answer in case there was more to come ;)
    – Hektor
    Oct 2, 2018 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.