Forums / Developer / Create file and assign to node

Create file and assign to node

Author Message

Sergi A

Monday 01 March 2010 2:17:27 am

Hi,

i'm currently developing a complex issue regarding nodes creation and ezBinaryFile attribute. The idea is to let the users create a new node that has a file type attribute, but this file is not uploaded by the user but created on the server-side once the user has filled the form. The content of this file will be a string generated when the user is creating it. This string would reach the kernel as a post variable, like any other attribute.

Then, when the user creates a node of this type, I need to create an ezBinaryFile , fill it with the string, and set it as an attribute of the new node.

I think that the different stages of this flow will be:

 

1. Create object as usual -> action.php

2. Form with all attributes -> edit/obj_id/version

action of this form goes to the same edit.php.. so i think here is where I should:

a) create the file on the server side

b) store the node

I guess that creating the file implies creating a temporary one and then call to ezbinaryfiletype::insertRegularFile, because the content of the destination file is filled copying directly the source file to the destination:

copy( $filePath, $destination );

but in my case, there is no source file but source string.. is there any function that does it in ez framework?

Then I would be able to create the node from the attributes, but i'm not sure how to do it... actually it is not create but edit, as i understood. This editing is peformed on conten/edit.php, where i think i should call to the file creation function. Is this ok?

Sorry for the large post, but i'm a bit confused and i need experts opinion on this complex issue.

Thank you!

Damien MARTIN

Wednesday 10 March 2010 12:53:45 am

Hi,

Maybe this could help you :

http://translate.google.com/translate?js=y&prev=_t&hl=fr&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Fpwet.fr%2Fblog%2Fcomment_creer_des_objets_ez_publish_en_php&sl=auto&tl=en

Damien