最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

uploads - Copying uploaded images not working in wordpress

programmeradmin4浏览0评论

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

$this->remove_uploaded_files();

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.

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

$this->remove_uploaded_files();

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.

Share Improve this question edited Oct 2, 2018 at 18:30 Hektor asked Sep 30, 2018 at 23:19 HektorHektor 1113 bronze badges 1
  • Maybe this helps: wordpress.stackexchange.com/questions/314529/… – Pim Commented Oct 1, 2018 at 7:57
Add a comment  | 

2 Answers 2

Reset to default 1

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.

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.

发布评论

评论列表(0)

  1. 暂无评论