When you attach a file to a node, you go to "File attachments", browse file, click attach.... after uploading the file under Description there is an url to the attached. We can copy this url and paste it in Body of our node (for example to make additional link).
The problem is that this url doesn't take into account that "Upload path" is being used. So this url shows for example:
http://domain.com/files/nissan.jpg
but after submiting a node the attachment is saved in
http://domain.com/files/blog/user/nissan.jpg
So the first url showed under Description can only confuse the user. Can we block showing that url or change somehow to show the correct one?
Comments
Comment #1
David Stosik commentedHello,
I need this too.
Thanks,
David
Comment #2
dennys commentedPlease consider to fix it. Although the function still works, but users will be confused.
Comment #3
Crell commentedThis is a known issue. However, I really don't know how to fix it given the way the upload module works. :-/ If anyone has suggestions on how to do so, please share. (Or a patch would be even better.)
Comment #4
dennys commentedA stupid way: modify modules/upload/upload.module, remark the 2 lines 777,778 and user will NOT see the url. If they doesn't see it, then they will not be confused :p
But I think if we need this function, maybe we need to modify upload module, not upload path module.
Comment #5
dennys commentedI tried to modify upload.module, it seems ok.
old:
new:
But I found another issue, I can use "u[author-uid]" as the prefix in upload path module, but I cannot use it in upload module. Is it due to the node is not generated yet, so the [author-uid] is null?
When I change to use "u[user-id]" as the prefix in upload path, it's ok in both upload and upload path.
Comment #6
Crell commentedThanks dennys, although modifying core is not something this module can do. :-) As for the other issue, please file that as a new issue. It's very hard to track issues that are mixed into one thread. Thanks.
Comment #7
murzSubscribe. Will be good to see the real path in state after uploading file, but I don't know how to do it without hacking the upload.module. Maybe use a
hook_form_alter()for upload file submitting form?Comment #8
livingegg commentedSubscribing.
Comment #9
joshvalentin commentedI changed upload.module as well to solve this, using a str_replace to replace "files/" with "files/".$usersrole where $usersrole is the logged in user's role. This custom code was on the line after the one stated above, where I use the str_replace on the $description=" line. I have the uploadpath module customized to upload files to user's ROLES. Using a customized token module with uploadpath and changing the upload.module file, I have a nice setup that works for Drupal 5.7.
Comment #10
David Stosik commentedBut you hacked core...
Comment #11
jureb commentedIs this feature of correct filepath at upload (and before the node post) really impossible to somehow get implemented in Uploadpath module?
I just installed Uploadpath module and before that moved all the old files to new locations, changed all the paths in files table, corrected all the urls in node_revisions table and it all works perfectly, besides this feature - my problem is, that I have a lot of users on my site and majority will have problems with inserting images. Yes, I'll make some banner on the content/add page, but this feature would be far better solution. If there is any way to help.
At least someone gives me the change of Drupal 6.x upload module (even though I wouldn't like to change core).
Comment #12
decipheredOne solution would be to have the module check the Body field for the old paths and replace them with the new paths after relocating/renaming the files.
While it would be great to know the correct path on upload, node tokens are not set in stone until the node has been saved.
Comment #13
bjorpe commentedI started working on an uploadpath_form_alter hook to avoid hacking core. It's possible to get working for simple cases.
The major problem with finding a gereral solution is that lots of tokens will not work when adding a new node (node object/information is missing). Possibly some node information could be gathered in a temporary node object, but it world not be 100% correct.
Also, it would be good for implementing this to extract the rewriting code of uploadpath_nodeapi into a separate function.
Here's the code if anyone wants to have a try (working with only a standard prefix):
Comment #14
AliraSirin commentedThanks for the idea, I made some tweaking with bjorpe's code and now it really works for default token [type/yyyy/mm] and any other token which contains only type and/or date items. Someone may proceed with tweaking and at least add other type-based tokens support (now it is possible).
Comment #15
livingegg commentedHow about some client-side code (jquery?) that somehow gets triggered after the page render is finalized and then dynamically modifies the link in the DOM?
Comment #16
pumpkinkid commentedHmm, subscribing
Comment #17
bmdhussain commentedWhen uploading a file using standard file attachment feature with AHAH callback it uploads the file in file/ path.
If we save the node or content the upload path module uploads the file in the folder path we configured in the admin settings.
This should not be happened. Any solutions?
Comment #18
Crell commented