Forums / Developer / reading an uploaded file content

reading an uploaded file content

Author Message

Peretjatko Alexandre

Thursday 19 June 2008 3:18:12 am

Hi,

I'm looking for a way to read ( in PHP ) a file that have been uploaded by the user via the Back Office.

Well.... I know, in PHP I can read my file with the <i>file</i> instruction like that :

$l_TAB_Fichier	= file($l_STR_FilePath );

.. but my trouble is to found the file's path ( my file is a text file )

I've found a way to acces to my file-object in the ezcontentobject table... but I don't know how to build the file path.

So, if someone know how to read an uploaded file content, help is welcome.

Regards

Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr

Pascal Specht

Thursday 19 June 2008 5:20:20 am

Hi Alexandre,

Maybe you can find your solution by reverse-engineering what eZBinaryFileHandler does:

$fileHandler =& eZBinaryFileHandler::instance();
$result = $fileHandler->handleDownload( $contentObject, $contentObjectAttribute, EZ_BINARY_FILE_TYPE_FILE );

Hope this helps,
</Pascal>

Peretjatko Alexandre

Thursday 19 June 2008 5:35:01 am

Hi Pascal,

In your code,

if $contentObject is the value that I found in ezcontentobject table ( column ID ), what would be $contentObjectAttribute ?

Regards

Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr

Pascal Specht

Thursday 19 June 2008 6:05:51 am

Hi Alexandre,

the contentObjectAttribute argument is the eZContentObjectAttribute of the ContentObject (see eZContentObjectAttribute documentation here:http://pubsvn.ez.no/doxygen/trunk/html/classeZContentObjectAttribute.html).
The code was a snipped from eZ's source code, not working out of the box.

What I meant is that you can start looking at how this has been implemented, how eZ Publish does it.

(from kernel/classes/ezbinaryfilehandler.php)

$fileInfo = $contentObjectAttribute->storedFileInformation( $contentObject, $version,
            $contentObjectAttribute->attribute( 'language_code' ) );

one typical way to get COA (ContentObjectAttributes) from a contentobject is for example:

$contentObjectAttributes =& $contentobject->contentObjectAttributes( false, false, $language, false );

</Pascal>

eZ debug

Timing: Jan 18 2025 22:11:18
Script start
Timing: Jan 18 2025 22:11:18
Module start 'content'
Timing: Jan 18 2025 22:11:18
Module end 'content'
Timing: Jan 18 2025 22:11:18
Script end

Main resources:

Total runtime0.5665 sec
Peak memory usage4,096.0000 KB
Database Queries61

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 587.7188180.8281
Module start 'content' 0.00700.5541 768.5469555.1016
Module end 'content' 0.56110.0053 1,323.648446.1016
Script end 0.5664  1,369.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.5178140.0002
Check MTime0.00120.2197140.0001
Mysql Total
Database connection0.00090.156410.0009
Mysqli_queries0.515691.0198610.0085
Looping result0.00070.1179590.0000
Template Total0.534894.420.2674
Template load0.00180.310720.0009
Template processing0.533194.103020.2665
Template load and register function0.00020.027010.0002
states
state_id_array0.00140.251910.0014
state_identifier_array0.00160.282520.0008
Override
Cache load0.00150.2704320.0000
Sytem overhead
Fetch class attribute can translate value0.00120.206720.0006
Fetch class attribute name0.00190.332450.0004
XML
Image XML parsing0.00230.398920.0011
class_abstraction
Instantiating content class attribute0.00000.003560.0000
General
dbfile0.00320.5649180.0002
String conversion0.00000.001630.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/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: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs