icefusion

Zend_File_Transfer_Adapter_Http

Dec 11th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. private function jpgUpload($data, $order, $path) {
  2.         $imageAdapterJPG = new Zend_File_Transfer_Adapter_Http();        
  3.         try {
  4.             if (file_exists($path)) {
  5.                 $diretorio = dir($path);
  6.                 while ($arquivo = $diretorio->read()) {
  7.                     unlink($path . '/' . $arquivo);
  8.                 }
  9.                 $diretorio->close();
  10.                 $imageAdapterJPG->setDestination($path);
  11.                 if (is_uploaded_file($data['tmp_name'])) {
  12.                     if (!$imageAdapterJPG->receive()) {
  13.                         die('Erro - Arquivo Não Recebido');
  14.                     }
  15.                 } else {
  16.                     die('Not Upload');
  17.                 }
  18.             } else {
  19.                 if (mkdir($path, 0777)) {
  20.                     $imageAdapterJPG->setDestination($path);
  21.                     if (is_uploaded_file($data['tmp_name'])) {
  22.                         if (!$imageAdapterJPG->receive()) {
  23.                             die('Erro - Arquivo Não Recebido');
  24.                         }
  25.                     } else {
  26.                         die('Not Upload');
  27.                     }
  28.                 }
  29.             }
  30.         } catch (Exception $e) {
  31.             var_dump($e);
  32.             exit;
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment