Closed (duplicate)
Project:
Mailsave
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
31 May 2009 at 21:41 UTC
Updated:
21 Jul 2010 at 19:47 UTC
Jump to comment: Most recent file
I have a node type that holds an imagefield. I have setup its path to be [user-id]/[site-date-YYYY]/[site-date-MM]/[site-date-DD].
When I use mailsave_to_imagefield, the files are not saved to this directory because it is not created on the fly when it does not exist. I have traced the code to that problem and I'm not sure there is a good solution (there must be... this is drupal).
It's all happening in _mailsave_to_imagefield_attempt_image() whene iterating the attachements
// Let's create the directory path if it hasn't been created already
$directory = file_create_path($widget_image_path);
file_check_directory($directory, FILE_CREATE_DIRECTORY);
That first line does not create the directory is it doesn't exist when it really should. That's because PHP's realpath() returns an empty string when a path does not exist (at least in 5.x)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | mailsave_to_video-HackedUp.zip | 4.99 KB | kloewer |
| #3 | Mailsave-Module-hacked-up-and-fixed-and-refixed.zip | 46.02 KB | kloewer |
| #3 | mailhandler-6.x-1.8.zip | 32.6 KB | kloewer |
Comments
Comment #1
PGiro commentedHere is my unsatisfactory fix but I can't think of anything better at the moment
Comment #2
mfbThanks, I incorporated this patch in #315381: make mailsave_to_imagefield work with mailhandler for importing images to cck imagefields.
Comment #3
kloewer commentedHow i "succeded"
My Fix was replacing Line 107 in mailsave_to_imagefield.module
with
Note: I had to remove the trailing slash /
$destination = file_destination(file_create_path($widget_image_path .' / '. $file['filename']), FILE_EXISTS_RENAME);
With a little help...
I also downgraded to mailhandler 6.x-1.8 and downloaded an complete package of mailsave with fixed mailsave_to_imagefield from this post:
http://drupal.org/node/714402
Steps
Attached is my complete Version of Mailsave-Fixed-Refix and Mailhandler.
Comment #4
alberto56 commentedConfirming that the solution in comment number 3 works. I tried it (make sure you use mailhandler 1.8, not the latest version):
Thanks to kloewer. Note that there are four other issues pertaining to this:
This issue we are on now is already marked as a duplicate, and I've marked the three others as duplicates, of #315381: make mailsave_to_imagefield work with mailhandler for importing images to cck imagefields. so let me suggest we continue the discussion there.
Comment #5
kloewer commentedSame issue with mailsave_to_video
Solution: http://drupal.org/node/774294#comment-3063090
Comment #6
chadwick wood commentedI just wanted to say that yes, comment #3 did work for me. ALSO, it's working using the latest version of mailhandler, which is 1.11. However, I did NOT need to make the change that kloewer made to generate $destination... the '/' does not need to be removed... I'm guessing he needed to remove it because there was a trailing slash on his $widget_image_path, but the imagefield module specifically says that there should not be. So, the only code that should need to be changed from what's described in http://drupal.org/node/714402 is around line 107:
So, now we've got a fix for this module with the latest version of mailhandler... how about an update? :)