當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ftp::delete_file方法代碼示例

本文整理匯總了PHP中Ftp::delete_file方法的典型用法代碼示例。如果您正苦於以下問題:PHP Ftp::delete_file方法的具體用法?PHP Ftp::delete_file怎麽用?PHP Ftp::delete_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ftp的用法示例。


在下文中一共展示了Ftp::delete_file方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $menu = $model->attributes;
     if (isset($_POST['FrontMenu'])) {
         $model->attributes = $_POST['FrontMenu'];
         foreach ($this->uploadArr as $column) {
             $file = CUploadedFile::getInstance($model, $column);
             //獲取表單名為filename的上傳信息
             if ($file) {
                 $model->{$column} = $this->uploadIcon($file);
                 if ($menu[$column]) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file('common/frontmenu/' . $menu[$column]);
                     $ftp->close();
                 }
             } else {
                 unset($model->{$column});
             }
         }
         if (!$model->ParentID) {
             $model->ParentID = 0;
         }
         if ($model->save()) {
             $this->freshMenuCache();
             $this->redirect(array('admin'));
         }
     }
     $this->render('update', array('model' => $model));
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:35,代碼來源:FrontmenuController.php

示例2: actionEditlogo

 public function actionEditlogo()
 {
     $organID = Yii::app()->user->OrganID;
     //organ表單驗證
     $model = Organ::model()->findByPK($organID);
     if ($model->Logo) {
         //刪除
         $ftp = new Ftp();
         $res = $ftp->delete_file($model->Logo);
         $ftp->close();
     }
     //獲得一個CUploadedFile的實例
     $file = CUploadedFile::getInstanceByName('Logo');
     $rs = array('code' => 100, 'msg' => '上傳失敗!' . $ImgName . '已經上傳');
     $upload = Yii::app()->params['uploadPath'] . 'tmp/logo/' . $organID . '/';
     $path = Yii::app()->params['uploadPath'] . 'tmp/';
     if (!is_dir($upload)) {
         mkdir($upload, 0777, true) or die('創建失敗');
         chmod($upload, 0777);
     }
     // 判斷實例化是否成功
     if (is_object($file) && get_class($file) === 'CUploadedFile') {
         $model->Logo = 'logo/' . $organID . '/' . 'file_' . date("YmdHis") . '_' . rand(1000, 9999) . '.' . $file->extensionName;
         //定義文件保存的名稱
     }
     /* else{  // 若果失敗則應該是什麽圖片  
        $model->url = './assets/upfile/noPic.jpg';
        } */
     if ($model->save()) {
         $file->saveAs($path . $model->Logo, true);
         $ftp = new Ftp();
         $res = $ftp->uploadfile($path . $model->Logo, $model->Logo);
         $ftp->close();
         @unlink($path . $model->Logo);
     }
     $this->redirect(array('index'));
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:37,代碼來源:InfomanagerController.php

示例3: editscheme

 public static function editscheme($params)
 {
     $organID = Yii::app()->user->getOrganID();
     $time = $_SERVER['REQUEST_TIME'];
     //更新報價單
     $quoID = self::ifsendquo(array('inqid' => $params['inqid']));
     $quodatas['UpdateTime'] = $time;
     $quodatas['Title'] = $params['quoname'];
     $result = Yii::app()->papdb->createCommand()->update('pap_quotation', $quodatas, 'QuoID=' . $quoID);
     $SchID = $params['schid'];
     $datas['TotalFee'] = $params['quoprices'];
     $datas['GoodFee'] = $params['totalprices'];
     $datas['ShipFee'] = $params['shipprices'];
     $datas['ShipFee'] = $params['shipprices'];
     $datas['UpdateTime'] = $time;
     //保存附件
     if ($params['fileurl']) {
         $datas['FileName'] = $params['filename'];
         $datas['FileUrl'] = $params['fileurl'];
         //刪除之前附件
         $quo_data = PapQuotationScheme::model()->findByPk($SchID);
         if (!empty($quo_data['FileName'])) {
             $ftp = new Ftp();
             $res = $ftp->delete_file($quo_data->FileUrl);
             $ftp->close();
         }
     }
     $result = Yii::app()->papdb->createCommand()->update('pap_quotation_scheme', $datas, 'SchID=:SchID', array(':SchID' => $SchID));
     //獲取商品信息
     $goodsinfo = array();
     $goodsids = explode(',', $params['quoids']);
     $goodsnum = explode(',', $params['quonum']);
     $goodsprice = explode(',', $params['quoprice']);
     //獲取以前的商品信息
     $oldgoodsinfo = PapQuotationGoods::model()->findAll('SchID=' . $SchID);
     $newgoodsinfo = array();
     foreach ($goodsids as $key => $v) {
         if ($v) {
             $newgoodsinfo[$key]['GoodsID'] = $goodsids[$key];
             $newgoodsinfo[$key]['Num'] = $goodsnum[$key];
             $newgoodsinfo[$key]['Price'] = $goodsprice[$key];
             $version = QuotationService::getgoodsversion($goodsids[$key]);
             $newgoodsinfo[$key]['Version'] = $version ? $version : 0;
         }
     }
     $insertid = array();
     //將報價單商品插入報價單商品表中
     if ($SchID) {
         foreach ($newgoodsinfo as $nkey => $new) {
             $newids[] = $new['GoodsID'];
         }
         if ($oldgoodsinfo) {
             foreach ($oldgoodsinfo as $okey => $old) {
                 $oldids[] = $old['GoodsID'];
             }
         } else {
             $oldids = array();
         }
         foreach ($oldids as $id) {
             if (!in_array($id, $newids)) {
                 //刪除商品
                 $delcount = Yii::app()->papdb->createCommand()->delete('pap_quotation_goods', 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
             }
         }
         foreach ($newids as $key => $id) {
             if (in_array($id, $oldids)) {
                 //更新商品
                 $update['Num'] = $newgoodsinfo[$key]['Num'];
                 $update['Price'] = $newgoodsinfo[$key]['Price'];
                 $update['Version'] = $newgoodsinfo[$key]['Version'];
                 $result = Yii::app()->papdb->createCommand()->update('pap_quotation_goods', $update, 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
                 if ($result == 1) {
                     $res = 1;
                 }
             } else {
                 //插入商品
                 $goodsdatas['SchID'] = $SchID;
                 $goodsdatas['GoodsID'] = $newgoodsinfo[$key]['GoodsID'];
                 $goodsdatas['Num'] = $newgoodsinfo[$key]['Num'];
                 $goodsdatas['Price'] = $newgoodsinfo[$key]['Price'];
                 $goodsdatas['Version'] = $newgoodsinfo[$key]['Version'];
                 $result = Yii::app()->papdb->createCommand()->insert('pap_quotation_goods', $goodsdatas);
                 $insertid[] = Yii::app()->papdb->getLastInsertID();
             }
         }
     }
     if ($res = 1 || count($insertid) > 0 || $delcount > 0) {
         echo json_encode(array('count' => 1, 'schid' => $SchID, 'success' => true));
     } else {
         echo json_encode(array('count' => 0));
     }
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:92,代碼來源:InquiryService.php

示例4: file_remote_delete

function file_remote_delete($file)
{
    global $_W;
    if (empty($file)) {
        return true;
    }
    if ($_W['setting']['remote']['type'] == '1') {
        require IA_ROOT . '/framework/library/ftp/ftp.php';
        $ftp_config = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout'], 'rootdir' => $_W['setting']['remote']['ftp']['dir']);
        $ftp = new Ftp($ftp_config);
        if (true === $ftp->connect()) {
            if ($ftp->delete_file($file)) {
                return true;
            } else {
                return error(1, '刪除附件失敗,請檢查配置並重新刪除');
            }
        } else {
            return error(1, '刪除附件失敗,請檢查配置並重新刪除');
        }
    } elseif ($_W['setting']['remote']['type'] == '2') {
        require IA_ROOT . '/framework/library/alioss/sdk.class.php';
        $oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['ossurl']);
        $response = $oss->delete_object($_W['setting']['remote']['alioss']['bucket'], $file);
        if ($response->status == 204) {
            return true;
        } else {
            return error(1, '刪除oss遠程文件失敗');
        }
    }
    return true;
}
開發者ID:zhang19960118,項目名稱:html11,代碼行數:31,代碼來源:file.func.php

示例5: actionSavedealerorgan

 /**
  * 公司信息保存
  */
 public function actionSavedealerorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $Organ = Yii::app()->request->getParam("Organ");
     $arr = Yii::app()->request->getParam("telPhone");
     $TelPhone = "";
     foreach ($arr as $key => $val) {
         if (empty($val)) {
             continue;
         }
         $TelPhone .= $val . ",";
     }
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ數據
     $model->attributes = $Organ;
     $model->TelPhone = trim($TelPhone, ',');
     //判斷基本信息是否為空,為空則不提交
     if ($Organ) {
         //接收刪除圖片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判斷是否刪除圖片
         if (!empty($photoId)) {
             $imageids = explode(',', $photoId);
             foreach ($imageids as $imageid) {
                 $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                 //判斷該圖片路徑是否存在數據庫中
                 if (empty($picture)) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($imageid);
                     $ftp->close();
                 } else {
                     OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($picture->Path);
                     $ftp->close();
                 }
             }
         }
         //接收上傳圖片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判斷是否有上傳圖片
         if (!empty($goodsImages)) {
             $imglegth = count($goodsImages);
             for ($i = 0; $i < $imglegth; $i++) {
                 $goodsImg = new OrganPhoto();
                 $goodsImg->OrganID = $OrganID;
                 $goodsImg->Path = $goodsImages[$i];
                 $goodsImg->save();
             }
         }
         //判斷是否上傳營業執照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $ftp = new Ftp();
                 $res = $ftp->delete_file($model->BLPoto);
                 $ftp->close();
             }
             $model->BLPoto = $BLPoto;
         }
         //接收dealer數據
         $dealer = Yii::app()->request->getParam("Dealer");
         //保存dealer數據
         $dealermodel = Dealer::model()->find("OrganID=:organid", array(":organid" => $OrganID));
         if (empty($dealermodel)) {
             //判斷是否第一次添加
             $dealermodel = new Dealer();
             $dealermodel->OrganID = $OrganID;
         }
         $dealermodel->SaleMoney = $dealer['SaleMoney'];
         $dealermodel->SaleDomain = $dealer['SaleDomain'];
         $dealermodel->ShopArea = $dealer['ShopArea'];
         if ($dealermodel->save() && $model->save()) {
             //保存成功
             $this->redirect(array('index'));
         } else {
             var_dump($dealermodel->errors);
             var_dump($model->errors);
             die;
         }
     }
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:88,代碼來源:DealercompanyController.php

示例6: actionSaveserviceorgan

 /**
  * 公司信息保存
  */
 public function actionSaveserviceorgan()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $Organ = Yii::app()->request->getParam("Organ");
     $arr = Yii::app()->request->getParam("telPhone");
     $TelPhone = "";
     foreach ($arr as $key => $val) {
         if (empty($val)) {
             continue;
         }
         $TelPhone .= $val . ",";
     }
     $model = Organ::model()->findByPK($OrganID);
     if (empty($model)) {
         $model = new Organ();
     }
     //保存organ數據
     $model->attributes = $Organ;
     $model->TelPhone = trim($TelPhone, ',');
     //判斷基本信息是否為空,為空則不提交
     if ($Organ) {
         //接收刪除圖片的地址
         $photoId = Yii::app()->request->getParam("photoId");
         //判斷是否刪除圖片
         if (!empty($photoId)) {
             $imageids = explode(',', $photoId);
             foreach ($imageids as $imageid) {
                 $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                 //判斷該圖片路徑是否存在數據庫中
                 if (empty($picture)) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($imageid);
                     $ftp->close();
                 } else {
                     OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
                     $ftp = new Ftp();
                     $res = $ftp->delete_file($picture->Path);
                     $ftp->close();
                 }
             }
         }
         //接收上傳圖片地址
         $goodsImages = Yii::app()->request->getParam("goodsImages");
         //判斷是否有上傳圖片
         if (!empty($goodsImages)) {
             $imglegth = count($goodsImages);
             for ($i = 0; $i < $imglegth; $i++) {
                 $goodsImg = new OrganPhoto();
                 $goodsImg->OrganID = $OrganID;
                 $goodsImg->Path = $goodsImages[$i];
                 $goodsImg->save();
             }
         }
         //判斷是否上傳營業執照
         $BLPoto = Yii::app()->request->getParam("BLPoto");
         if ($model->BLPoto != $BLPoto) {
             if (!empty($model->BLPoto)) {
                 $ftp = new Ftp();
                 $res = $ftp->delete_file($model->BLPoto);
                 $ftp->close();
             }
             $model->BLPoto = $BLPoto;
         }
         //接收service數據
         $service = Yii::app()->request->getParam("Service");
         $opentime = Yii::app()->request->getParam("OpenTime");
         //保存service數據
         $servicemodel = Service::model()->find("OrganID=:organid", array(":organid" => $OrganID));
         if (empty($servicemodel)) {
             //判斷是否第一次添加
             $servicemodel = new Service();
             $servicemodel->OrganID = $OrganID;
         }
         $servicemodel->PositionCount = $service['PositionCount'];
         $servicemodel->TechnicianCount = $service['TechnicianCount'];
         $servicemodel->ParkingDigits = $service['ParkingDigits'];
         $servicemodel->ReservationMode = $service['ReservationMode'];
         $servicemodel->ShopArea = $service['ShopArea'];
         $servicemodel->OpenTime = $opentime[0] . ',' . $opentime[1] . ',' . $opentime[2] . ',' . $opentime[3];
         //$model->attributes = $Organ;
         if ($servicemodel->save() && $model->save()) {
             //保存成功
             //$file->saveAs(Yii::app()->params['uploadPath'].$model->Logo, true);
             $this->redirect(array('index'));
         } else {
             var_dump($goodsImg->errors);
             die;
         }
     }
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:93,代碼來源:ServicecompanyController.php

示例7: delorganphoto

 public function delorganphoto($photoId)
 {
     $imageids = explode(',', $photoId);
     $OrganID = Yii::app()->user->getOrganID();
     $ftp = new Ftp();
     foreach ($imageids as $imageid) {
         $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
         //判斷該圖片路徑是否存在數據庫中
         if (empty($picture)) {
             $res = $ftp->delete_file($imageid);
         } else {
             OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
             $res = $ftp->delete_file($picture->Path);
         }
     }
     $ftp->close();
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:17,代碼來源:ActivecompanyController.php

示例8: file_remote_delete

function file_remote_delete($file)
{
    global $_W;
    if (empty($file)) {
        return true;
    }
    if ($_W['setting']['remote']['type'] == '1') {
        require_once IA_ROOT . '/framework/library/ftp/ftp.php';
        $ftp_config = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout'], 'rootdir' => $_W['setting']['remote']['ftp']['dir']);
        $ftp = new Ftp($ftp_config);
        if (true === $ftp->connect()) {
            if ($ftp->delete_file($file)) {
                return true;
            } else {
                return error(1, '刪除附件失敗,請檢查配置並重新刪除');
            }
        } else {
            return error(1, '刪除附件失敗,請檢查配置並重新刪除');
        }
    } elseif ($_W['setting']['remote']['type'] == '2') {
        require_once IA_ROOT . '/framework/library/alioss/sdk.class.php';
        $oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['ossurl']);
        $response = $oss->delete_object($_W['setting']['remote']['alioss']['bucket'], $file);
        if ($response->status == 204) {
            return true;
        } else {
            return error(1, '刪除oss遠程文件失敗');
        }
    } elseif ($_W['setting']['remote']['type'] == '3') {
        require_once IA_ROOT . '/framework/library/qiniu/autoload.php';
        $auth = new Qiniu\Auth($_W['setting']['remote']['qiniu']['accesskey'], $_W['setting']['remote']['qiniu']['secretkey']);
        $bucketMgr = new Qiniu\Storage\BucketManager($auth);
        $error = $bucketMgr->delete($_W['setting']['remote']['qiniu']['bucket'], $file);
        if ($error instanceof Qiniu\Http\Error) {
            if ($error->code() == 612) {
                return true;
            }
            return error(1, '刪除七牛遠程文件失敗');
        } else {
            return true;
        }
    }
    return true;
}
開發者ID:weikit,項目名稱:wechat-addon,代碼行數:44,代碼來源:file.func.php

示例9: actionDelPto

 public function actionDelPto()
 {
     $imageid = Yii::app()->request->getParam("imageid");
     $ftp = new Ftp();
     $res = $ftp->delete_file($imageid);
     $ftp->close();
     echo json_encode($res);
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:8,代碼來源:OrderreviewController.php

示例10: actionFtpDelfile

 public function actionFtpDelfile()
 {
     if (Yii::app()->user->isGuest) {
         echo json_encode(array('res' => 0, 'msg' => '請先登錄'));
         die;
     }
     if (Yii::app()->request->isAjaxRequest) {
         $path = Yii::app()->request->getParam('path');
         $ftp = new Ftp();
         $res = $ftp->delete_file($path);
         $ftp->close();
         if ($res['success']) {
             echo json_encode(array('res' => 1));
         } else {
             echo json_encode(array('res' => 0));
         }
     }
 }
開發者ID:zwq,項目名稱:unpei,代碼行數:18,代碼來源:UploadController.php


注:本文中的Ftp::delete_file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。