Forums / General / eZContentUpload question

eZContentUpload question

Author Message

Carlos Revillo

Tuesday 26 June 2007 1:27:31 pm

Hi. I'm working in a extension. I want some users can add articles to the site, and some related object (pdf files, zip files... ). to them.

So i'm trying to do it using ezContentUpload class, but i have no luck.

what i'm doing is something like this

 $upload = new eZContentUpload( );
 $upload->handleUpload($result,"file1","auto","false");

where "file1" is the name of one of the file inputs coming from post.

These users has also rights to create new content at media section. But i don't see any changes in the tree content of that section.

So i have some questions.

Do i have to publish this object maybe using something like

$upload->publishObject(...);

?

If yes, how do i have to call this function? i'm trying with

 $upload = new eZContentUpload( );
 $upload->handleUpload($result,"file1","auto","false");
$upload->publishObject($result);

but i get

Fatal error: Call to a member function on a non-object in .../kernel/classes/ezcontentupload.php on line 698
Fatal error: eZ publish did not finish its request
The execution of eZ publish was abruptly ended, the debug output is present below.

Looking to that line of that class it seems like the function needs and $object to work, but i don't know what "object" do i have to pass to the function...

anyone can help me with this? thanks.

Łukasz Serwatka

Tuesday 26 June 2007 11:40:54 pm

Hi,

You can use insertHTTPFile() method which is available for ezimage, ezbinaryfile, ezmedia datatypes.

More info:
http://ez.no/download/ez_publish/changelogs/ez_publish_3_5/general_insertion_interface_for_datatypes
http://ez.no/community/forum/developer/howto_use_ezcontentobjectattribute_setcontent_on_a_simple_text_datatype
http://pubsvn.ez.no/doxygen/trunk/html/classeZBinaryFileType.html#f8ff4fd587757aad674eef1cf0d4bfaf
http://pubsvn.ez.no/doxygen/trunk/html/ezbinaryfiletype_8php-source.html#l00368

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Carlos Revillo

Wednesday 27 June 2007 1:24:03 am

Hi and thanks Lukas. but i'm missing something.

I have used insertHTTPFile to add some binary content as the content of an attribute. But this is not the case.

I have no file attribs an my class. I want to add this uploaded file as a related object of a main node.

I try to explain it better. Let's suppose my test class has only one field. Let's called it name.

in my template i have an form with a text field for name and some input files fields to add files as related content, not as attributes of the object i'm creating.

Do you think insertHTTPFile could still be valid for my purpose?

Łukasz Serwatka

Wednesday 27 June 2007 1:33:31 am

Hi,

I suggest to use contetobjects anyway. Then you still need to create one more content object, e.g binary file where you will need to store file from user in attribute, then add relation using PHP to your primary object where is only "Name". You can also make structure where object with file is a child of primary object, then just fetch it in tpl.
Hope that will help you.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Carlos Revillo

Wednesday 27 June 2007 1:40:00 am

I see. Thanks a lot!.