How to move an image from temp folder to a folder inside the project in server in zend framework?

261 Views Asked by At

I have form where user can upload an image. I am working locally and when a user uploads a photo it added in the temp folder then I need to move it to folder inside the project. I need to know how to do this in live server.

Thanks

1

There are 1 best solutions below

0
opHASnoNAME On

If you want to do it with Zend Framework, use Zend_Filter_File_Rename:

    $moveTo = '/uploads';

    $upload = new Zend_File_Transfer_Adapter_Http();
    $upload->addValidator('Count', false, array('min' => 1, 'max' => 1))
           ->addValidator('Size', false, array('max' => '2000kB'))
           ->setDestination($moveTo);

    if (!$upload->isValid()) {
        return false;
    }


    $upload->receive();
    $name = $upload->getFileName();
    $newFile = "nefile.png";

    $filterFileRename = new Zend_Filter_File_Rename(array(
        'target'    => $moveTo . '/' . $nefile;
        'overwrite' => true
    ));
    $file = $filterFileRename->filter($name);