Forums / Developer / reading an uploaded file content

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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 Exponential 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>