http://drupal.org/project/uploadpath lets you define where you want files uploaded by users to go. It works on nodes but not on comments since normally comments can't have file attachments. I'd love to see these two modules working together so I can control where the files go whether they are uploaded to a node or a comment.

Thanks,

Michelle

Comments

Christefano-oldaccount’s picture

I'd like this.

subscribing.

heine’s picture

So do I. With http://drupal.org/node/136630 committed this can be implemented. Can't make promises on a time frame. Patches are always welcome.

Mac Clemmens’s picture

Amen. This feature would be most useful. Let me know if/how I can help. :)

heine’s picture

Status: Active » Needs review
StatusFileSize
new1.64 KB

Patch against 5.x-dev. It suffers from the same limitation as upload_path on node previews.

Christefano-oldaccount’s picture

This works for the most part but it looks like attachments on comments cannot use tokens like [nid] or [ogname]. I hesitate to change status to needs work because I don't know if this is a bug in Upload path or Comment Upload.

heine’s picture

StatusFileSize
new3.56 KB

No longer requires upload_path module.

We need two settings pages, because the comment_upload prefix needs its info from comment tokens, whereas the node uploads needs it from node tokens. We cannot use one variable for that.

Christefano-oldaccount’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks solid to me and works as advertised. Thanks, Heine!

heine’s picture

Status: Reviewed & tested by the community » Needs work

need to solve preview issue first (files/filename instead of files/token/filename)

Mac Clemmens’s picture

Any update here? I see previews in now working with the dev release -- nice work. Can this patch still be applied, and will it be committed?

Let me know if/how I can help.

Thanks,
Mac

Mac Clemmens’s picture

Is it possible to allow users to enter node tokens as well as comment tokens? (Like they do for file upload paths.) This would be very useful to ensure that files that are uploaded in comments end up in the same place as other files uploaded with the node.

Great patch work -- thanks!
Mac

+function comment_upload_change_upload_path(&$comment) {
+ $node = node_load($comment['nid']);
+ if (isset($comment['files'])) {
+ foreach ($comment['files'] as $key => $file) {
+ if (0 === strpos($key, 'upload_')) { // Only rewrite the name when adding the file, not when updating it
+ // Get the new, prefixed file name
+ $file_name = str_replace(array(' ', "\n", "\t"), '_', token_replace(variable_get('comment_uploadpath_prefix', '') . '/', 'comment', $comment)) . $comment['files'][$key]['filename'];
+
+ // Create the directory if it doesn't exist yet.
+ $dirs = explode('/', dirname($file_name));
+ $directory = file_directory_path();
+ while (count($dirs)) {
+ $directory .= '/' . array_shift($dirs);
+ file_check_directory($directory, FILE_CREATE_DIRECTORY);
+ }
+ // Change where the file will be saved to the specified directory.
+ $comment['files'][$key]['filename'] = $file_name;
+ }
+ }
+ }
+}

korvus’s picture

I'm interested in seeing this implemented as well. Has there been any progress?

Babalu’s picture

a d6 version of the patch would be great

CobraMP’s picture

bump. I am looking for a upload path. [title] preferably. casting my vote

heine’s picture

Status: Needs work » Closed (won't fix)

You can vote all you want, but this is not a democracy.

I am no longer interested in this; I don't need this functionality, none of my clients need it (atm) and as far as I know, Drupal.org doesn't need this either. Long story short: unless you have a good patch and got it tested, don't bother bumping.

Libra’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
StatusFileSize
new424 bytes
new3.68 KB

I create small patch for 6.x-1.x-dev version, which add upload path field (with token placeholders) to comment_upload settings and use this path for upload files.

Unfortunately, we can't use for 6.x version token placeholders for node object, because node object not accessible in comment_upload_process_files function.

elijah lynn’s picture

I vote for this too!

I was trying to use IMCE to upload files through comments but that seems unlikely, if upload_path can work with comment_upload then at least all the files the user does upload through tinymce/imce will go into the same directory as the files uploaded from comment_upload and upload modules.

Then they can use the file_browser in my_account and see all the files they have uploaded. Then when I finally figure out how to upload files with IMCE through comments they can re-use files.

michelle’s picture

If folks are really interested in this, you might want to set it active to get the attention of the current mantainer. I started the issue 2 years ago but am no longer interested. I am converting my site to all nodecomment / imagefield and not using the comment module anymore.

Michelle

that0n3guy’s picture

Just so everyone knows... filefield path module works with comment upload.

ilw’s picture

Just so everyone knows... filefield path module works with comment upload.

Thanks!