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>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 01:15:43
Script start
Timing: Jan 19 2025 01:15:43
Module start 'layout'
Timing: Jan 19 2025 01:15:43
Module start 'content'
Timing: Jan 19 2025 01:15:43
Module end 'content'
Timing: Jan 19 2025 01:15:43
Script end

Main resources:

Total runtime0.0179 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.1641152.6250
Module start 'layout' 0.00550.0034 741.789139.4453
Module start 'content' 0.00890.0065 781.234493.4609
Module end 'content' 0.01540.0024 874.695334.3047
Script end 0.0178  909.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002815.6345140.0002
Check MTime0.00137.1802140.0001
Mysql Total
Database connection0.00084.510310.0008
Mysqli_queries0.002815.916330.0009
Looping result0.00000.112210.0000
Template Total0.002011.010.0020
Template load0.00116.050210.0011
Template processing0.00094.929710.0009
Override
Cache load0.00084.414110.0008
General
dbfile0.00137.277780.0002
String conversion0.00000.057440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs