예제 #1
0
파일: Api.php 프로젝트: rgwybb/tars
 public function upload($product, $name)
 {
     $data = Flight::request()->data;
     $unCompress = $data->unCompress;
     $chmod = $data->chmod;
     if (!$unCompress) {
         $unCompress = 'true';
     }
     if (!$chmod) {
         $chmod = '644';
     }
     $files = isset($_FILES['ScriptFile']) ? $_FILES['ScriptFile'] : null;
     $pkg = new Pkg();
     $info = $pkg->getPackageInfo($product, $name);
     if ($info) {
         $base = $info['path'];
     } else {
         $base = '/' . $product . '/' . $name;
     }
     $path = $base . '/' . $data->path;
     $ret = $pkg->uploadFile($path, $files, $unCompress, $chmod);
     $error = $pkg->curlLastError();
     if ($error) {
         $result = array('result' => false, 'data' => $error->toArray());
     } elseif (!$ret || $ret['error']) {
         $result = array('result' => false, 'data' => $ret);
     } else {
         $result = array('result' => true, 'data' => $ret);
     }
     echo '<script>parent.pkgUploadFileDone(', json_encode($result), ')</script>';
 }