As you are trying to emulate file upload behaviour you must also provide the necessary hidden fields. Otherwise the upload could fail or the behaviour be unlogical. Your code is missing some necessary details.

Your description:
You are trying to upload file ONE... first file valid and uploaded. All seems to be ok (but there is one failure which you did not note). You are trying to upload file TWO... as the first file is uploaded isUploaded returns true, but isValid is false because the upload of the first file did not occur but it is checked first hand.

Greetings
Thomas

----- Original Message ----- From: "Sergio Rinaudo" <[email protected]>
To: <[email protected]>
Sent: Friday, July 02, 2010 9:26 PM
Subject: [fw-general] Zend_File_Transfer_Http strange behaviour



Hello,
I'm stuck in a problem with Zend_File_Transfer_Adapter_Http and I hope somebody could give me an advice.
I have an html form ( not zend form ) with 2 image element:

<input name="image" type="file" id="image" value="" />
<input name="image_foto" type="file" id="image_foto" value="" />

and I have this code that process the file elements

 $adapter = new Zend_File_Transfer_Adapter_Http();
 $adapter->setDestination("/my/destination/path");
 $adapter->addValidator('Extension', false, 'png,jpg,gif')
         ->addValidator('Size', false, 8388608)
->addValidator('ExcludeMimeType', false, 'application,audio,message,model,multipart,text,video');*/
 $files = $adapter->getFileInfo();

 foreach( $files as $fieldname => $fileinfo ) {

   $isUploaded = $adapter->isUploaded($fileinfo['name']);

   $isValid = $adapter->isValid($fileinfo['name']);

   try {

       $adapter->receive($fileinfo['name']);

   } catch(Zend_File_Transfer_Exception $e) {

       echo $e->getMessage();
       exit;

   }

 }

The strange behaviour is the value of $isUploaded and $isValid:


if I upload the same file as FIRST file ( id="image" ), both are true.

if I upload the same file as SECOND file (id="image_foto" ) and the first file EMPTY, $isUploaded is TRUE but isvalid is FALSE,

when the result I expect is both the value as TRUE.

Same behaviour if I disable all the validator.

Surely there is something I did not get, but what?

Thanks for all your help.

Sergio

_________________________________________________________________
Novità dai tuoi amici? Le trovi su Messenger
http://www.messenger.it/novita.aspx

Reply via email to