Upload problem (ez-publish 3.9.2)

Author Message

Jacques Feix

Wednesday 21 May 2008 2:39:59 am

Hi,
I have written a code to upload some files.
When I upload a js file, for example, the file is correctly uploaded
When I upload a pdf, doc or jpg file, the file is correctly created but it has a null size (=0)
When I check the $_FILES variable, the size is already to 0.. strange

here is my code :

 
        $upload = new eZContentUpload();			    		
	$errors="";
	$fichier = $_FILES[$filename];
	
	if($fichier['error'] ==0)
	{		
		    $upload->fetchHTTPFile( $filename,$errors, $file, $mimeData ) ;
		    if($errors=="")
		    {    			    	
		    	$file->store('path/'.time());
	    		return true;		    	    	
		    }
	 }                                
        return false;

any idea ?
thx :)

André R.

Wednesday 21 May 2008 3:57:25 am

Is the file bigger then what you allow in php settings?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jacques Feix

Wednesday 21 May 2008 4:59:31 am

Hi André,
I thought about it, but my file is only 154 ko
Also, I can upload it when I create a new "file" object

André R.

Wednesday 21 May 2008 5:36:12 am

Beats me, try this upload code from Oe ('fileName' is name on file input):

include_once( 'kernel/classes/ezcontentupload.php' );
$upload = new eZContentUpload();

$location = false;
if ( $http->hasPostVariable( 'location' ) )
{
    $location = $http->postVariable( 'location' );
    if ( $location === 'auto' || trim( $location ) === '' ) $location = false;
}

$objectName = '';
if ( $http->hasPostVariable( 'objectName' ) )
{
    $objectName = trim( $http->postVariable( 'objectName' ) );
}

$uploadedOk = $upload->handleUpload( $result, 'fileName', $location, false, $objectName );


if ( $uploadedOk )
{
    $newObject = $result['contentobject'];
    $newObjectID = $newObject->attribute( 'id' );
    //and so on
}
else
{
    foreach( $result['errors'] as $err )
        echo $err['description'] . '<br />';
}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jacques Feix

Wednesday 21 May 2008 6:23:07 am

André,
I can't use your code. each time the "handleUpload" function return an error :

the problem is here :

$locationOK = $this->detectLocations( $classIdentifier, $class, $location, $parentNodes, $parentMainNode );

I tried 'auto', and a correct nodeID for $location but it doesn't work
Also, I am not really interested by creating an eZPublish object with my file, I just want to upload it ...

thx,

Jacques Feix

Wednesday 21 May 2008 8:15:54 am

oupsssss
My firefox has a problem, when I do it with IE it is ok ...

Sorry for this post ..
:)

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