First the files are uploaded to the destination path using move_uploaded_file. This is done in background when you use receive() or any method which calls receive() in background.
Afterwards the filters are applied, and the file will be renamed.

The warning itself is thrown by php and means that it is not allowed to move (rename) the file from it's destination directory to the defined resourcepath.

I think that even if the directory is world wide accessable, there seems to be a problem with the file permission itself. You can simply test this out, by not applying the filter and then rename/move the file from within the same script "manually" from the destination path to the resourcepath.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com


----- Original Message ----- From: "Tim Nagel" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, November 03, 2008 1:59 AM
Subject: [fw-general] Zend_File_Transfer


Hello,

I am trying to write the server side component of a file uploading form,
which worked fine in its previous version with nothing to do with zend.
(using move_uploaded_file, rather than rename())

At this point, the front end is done and posts files as expected, the php
code:

 public function imageuploadAction()
 {
  if ($this->getRequest()->isPost())
  {
   $uploadAdapter = new Zend_File_Transfer_Adapter_Http(); // TODO: change
to Zend_File_Transfer when the factory is stable
   $resourcePath = APPLICATION_PATH .
Zend_Registry::get('config')->resourcepath . "/images";
   if (!is_dir($resourcePath))
   {
    throw new Exception('Savepath not found in config.ini or it isnt a
directory: ' . $resourcePath);
   }

   $uploadAdapter->addFilter('Rename', $resourcePath);
   if (!$uploadAdapter->receive())
   {
    $messages = $uploadAdapter->getMessages();
    echo implode('<br />', $messages); die;
    //throw new Infinite_Exception_SystemError('receive returned false');
   }
   echo "redirect to edit screen"; die;
  }
 }

Results in the file ending up in the appropriate location at the end,
however it results in the output:


*Warning*:
rename(/var/tmp/AccessibleMarshal.dll,/usr/home/share/webdocs/tnagel/project/application/resources/images/filename.jpg)
[function.rename <http://formalcars.tnagel/ad/imageupload/function.rename>]:
Operation not permitted in *
/usr/home/share/webdocs/tnagel/project/library/Zend/Filter/File/Rename.php*on
line
*206*
redirect to edit screen

The resource directory is world writable.

It does seem 'safe' to ignore the warning, I assume move_uploaded_file is
where the file is getting copied rather than rename?


Tim


Reply via email to