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!.

eZ debug

Timing: Jan 19 2025 15:20:07
Script start
Timing: Jan 19 2025 15:20:07
Module start 'content'
Timing: Jan 19 2025 15:20:08
Module end 'content'
Timing: Jan 19 2025 15:20:08
Script end

Main resources:

Total runtime0.9995 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.9297180.8438
Module start 'content' 0.00510.8993 769.7734573.2969
Module end 'content' 0.90450.0950 1,343.0703337.3984
Script end 0.9995  1,680.4688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3634210.0002
Check MTime0.00150.1523210.0001
Mysql Total
Database connection0.00070.070810.0007
Mysqli_queries0.937493.77782000.0047
Looping result0.00140.14401980.0000
Template Total0.971397.220.4857
Template load0.00170.171820.0009
Template processing0.969697.003220.4848
Template load and register function0.00020.022010.0002
states
state_id_array0.00120.119910.0012
state_identifier_array0.00100.095920.0005
Override
Cache load0.00150.1459420.0000
Sytem overhead
Fetch class attribute can translate value0.00140.137730.0005
Fetch class attribute name0.00080.076160.0001
XML
Image XML parsing0.00110.108130.0004
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00170.1721290.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs