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