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.


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 '18 at 7:21
  • Not sure if this has a solution for you? Check it out? youtu.be/-RtBrUCSkBk Oct 1 '18 at 7:43
  • If my answer was any help, please feel free to upvote :) Oct 1 '18 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 '18 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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