Hi
I have about 1000 files on my server and I need ability to attach them into existing nodes, I need feature alike this one in image_attach.module "choose image from server" (in this case "choose file from server).

Is there any way to achieve this? (this doesn't have to be with upload.module)

Comments

joeebel’s picture

I've got audio files that I'd like to attach to nodes. I want to use files already uploaded. Is there already a way to do that?

v8powerage’s picture

I found a module which theoretically does the job, It's "Media mover" but when I was trying choose files from server I got error (everything is in this issue #504090: "An HTTP error 404 occured" (during browsing from local folder).

Anonymous’s picture

Subscribe two !

I'll have a look at Web File Manager module.

v8powerage’s picture

I need a simple dropdown list like in image.attach moodule perhaps someone tried copy this feature into file.module?

avpaderno’s picture

Please, don't write a comment all in bold.

avpaderno’s picture

The only way to do what you want is to use the upload module.
It is not a good practice to modify Drupal core code, or modules. If there is a new version of Drupal that fixes a security problem, you should change the core module again, and repeat the operation all times there is a new version.

v8powerage’s picture

Well, that's rather obvious, and I didn't said that this must be done with upload module.

I'm just asking if somebody achieved this somehow to attach files existing in /files folder into nodes (dropdown list like in image_attach.module)?

Dan Silver’s picture

subscribing

v8powerage’s picture

anyone found some solution perhaps?

bsenftner’s picture

Just to be clear on your requirements: you want these files to appear as node attachments?

You could programmatically create nodes that either reference the files in their html or via the php input filter, and then you have the files at least referenced by the nodes, "visible" when their node is viewed. They're not attached as they would be if manually attached by interactively attaching them via the node creation form, but for the users of your site, it may not make a difference. If you have SWF Tools, and they are mp3 files, you could have the node play the songs when viewed. They'd just not be attached, only referenced.

If you really need them attached, that can also be done via programmatically creating nodes, but I've not done that myself.

These may help:
http://drupal.org/node/600590
http://drupal.org/node/293663

Note: I realize these are existing nodes... I believe, but have not tried myself, that you'd just need to submit your new node with the node id of the existing node, but increment the revision id (vid) to 'add' to the existing node.

v8powerage’s picture

Yes I have the nodes made already and I'd like to save them instead of creating new ones, as they're categorized and have some text.

Those files are mainly .rar and .pdf I was using ec_file module before, from ecommerce package and in fact I have the table where every file is attached into the corresponding node, but now I don't know how to make it working without the ecommerce modules. Perhaps I need some new module which would take the data from this table (I can give up file.module)?

Here's my post about it: http://drupal.org/node/597068

bsenftner’s picture

Okay, I think you can solve this with a variation of the 2nd link I gave above, this one:
http://drupal.org/node/293663

In that article is described a need to batch process the creation or updating of many nodes. The poster used drupal_excute() to solve this, and gave a great example to follow.

Have a look at the 2nd block of code in that post. One of the first things in that logic is a database query, followed by a conditional where a node is created or an existing node is loaded; your logic would operate in much the same way. After the if/else conditional, there are 3 small code fragments, each with a comment, before the call to drupal_excute(). You'll need pretty much the very same lines of code, except where the comment says "Set the form_state values", you'll replace those lines with "something else" that handles attaching these files to the new or just loaded node.

I located a link to information covering what that "something else" logic needs to be, but keep in mind that the author of this logic is running his php logic outside of drupal, on the command line. There is another technique I've seen where people write a drupal boot strap loader to create the drupal logical environment on the command line, and then batch process multiple changes to their web site. Perhaps you'll want to use this technique as well.
http://www.workingdirectory.net/posts/2009/attach-file-to-node-drupal-6/

The differences between the two examples are mostly that the first uses drupal_excute() (with an array node representation), and the second uses node_save() (with an object node representation). The file attachment logic should be pretty much the same in the drupal_execute() technique, but you'll need to convert the object node references in the node_save() version into array node references for use with drupal_execute().

Which ever method you select, if either of them, be sure to read a bit more than just those posts. In the drupal_excute() version, read the comments; they add some great information. For the node_save() version, that looks very much like some of my own code I use, but where they just use node_save(), I have: $node = node_submit( $node ); node_save( $node );. I read some thread here at drupal.org recommending to always have a node_submit() before a node_save(); I don't remember why, though...

I hope this helps. Let me know what you ended up doing.

v8powerage’s picture

Sorry, but it's just way too complicated for me.

I need a list of files in files/downloads folder, then I could manually attach them to corresponding nodes, like it's done in image_attach.module.

drein’s picture

The disknode module make what you want, but the development for drupal6 is quite slow. there is a porting version but gives some errors, anyway I am in the same situation. Disknode allows you to choose from you server and attach to nodes.

v8powerage’s picture

Thanks

I eventually found out that WebFM is the one for me (though a bit of set-up is needed to make what you want), anyway it seems to be the best replacement for the drupal's upload.module.

JoshuaKissoon’s picture

If your using filefield to create your file upload fields, filefield_sources might be your solution

http://drupal.org/project/filefield_sources