当前位置: 首页>>代码示例>>PHP>>正文


PHP Ftp::put方法代码示例

本文整理汇总了PHP中Ftp::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Ftp::put方法的具体用法?PHP Ftp::put怎么用?PHP Ftp::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ftp的用法示例。


在下文中一共展示了Ftp::put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * @param DatabaseBackupFile $file
  * @return ResultObject[]
  */
 public function process(DatabaseBackupFile $file)
 {
     $d = $file->getBackupDate();
     $results = [];
     foreach ($this->uploadsCredentials as $credentials) {
         $result = new ResultObject();
         // empty ResultObject means all is OK
         $backupPath = $credentials['path'] . '/' . $d->format('Y') . '/' . $d->format('F');
         $entireFilePath = $backupPath . '/' . $file->getFileName();
         try {
             $ftp = new \Ftp();
             $ftp->connect($credentials['host']);
             $ftp->login($credentials['username'], $credentials['password']);
             if (!$ftp->fileExists($backupPath)) {
                 $ftp->mkDirRecursive($backupPath);
             }
             $ftp->put($entireFilePath, $file->getFilePath(), FTP_BINARY);
             $ftp->close();
         } catch (\FtpException $e) {
             $this->logger->addCritical(sprintf('Uploading backup file\'s failed. %s', $e));
             $result->addError('Zálohu se nepodařilo nahrát na: ' . $credentials['host'], 'error');
         }
         $results[] = $result;
     }
     return $results;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:30,代码来源:DatabaseBackupFileHandler.php

示例2: fn_copy_by_ftp

/**
 * Copies files using FTP access
 *
 * @param string $source Absolute path (non-ftp) to source dir/file
 * @param string $destination Absolute path (non-ftp) to destination dir/file
 * @param array $ftp_access
 *      array(
 *          'hostname',
 *          'username',
 *          'password',
 *          'directory'
 *      )
 * @return bool true if all files were copied or (string) Error message
 */
function fn_copy_by_ftp($source, $destination, $ftp_access)
{
    try {
        $ftp = new Ftp();
        $ftp->connect($ftp_access['hostname']);
        $ftp->login($ftp_access['username'], $ftp_access['password']);
        $ftp->chdir($ftp_access['directory']);
        $files = $ftp->nlist('');
        if (!empty($files) && in_array('config.php', $files)) {
            $ftp_destination = str_replace(Registry::get('config.dir.root'), '', $destination);
            if (is_file($source)) {
                // File
                try {
                    $file = ltrim($ftp_destination, '/');
                    $ftp->put($file, $source, FTP_BINARY);
                } catch (FtpException $e) {
                    throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                }
            } else {
                // Dir
                $ftp->chdir($ftp_access['directory'] . $ftp_destination);
                $struct = fn_get_dir_contents($source, false, true, '', '', true);
                foreach ($struct as $file) {
                    $dir = dirname($file);
                    if (!$ftp->isDir($dir)) {
                        try {
                            $ftp->mkDirRecursive($dir);
                        } catch (FtpException $e) {
                            throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                        }
                    }
                    try {
                        $ftp->put($file, $source . $file, FTP_BINARY);
                    } catch (FtpException $e) {
                        throw new FtpException('ftp_access_denied' . ':' . $e->getMessage());
                    }
                }
            }
            return true;
        } else {
            throw new FtpException('ftp_directory_is_incorrect');
        }
    } catch (FtpException $e) {
        return __('invalid_ftp_access') . ': ' . $e->getMessage();
    }
    return false;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:61,代码来源:fn.fs.php

示例3: ftp_upload

 /**
  * ftp上传
  * @param $file_path:本地文件的路径
  * @param $savename:文件名 
  * @return 1;上传成功<br>
  *         0;上传失败
  */
 private function ftp_upload($ftp_file_path, $local_file_path, $savename, $type)
 {
     import("@.ORG.Ftp");
     $ftp = new Ftp();
     $conn = $ftp->connect('w1.weimg.cn', 'images', 'images580230', $port = '21', $pasv = false, $ssl = false, $timeout = 30);
     $ftp->mkdir($ftp_file_path);
     $res = $ftp->put($ftp_file_path . $savename, $local_file_path . $savename);
     if ($type == 4) {
         $ftp->put($ftp_file_path . 's_' . $savename, $local_file_path . 's_' . $savename);
         unlink('./Public/upload/s_' . $savename);
     }
     $ftp->close();
     unlink('./Public/upload/' . $savename);
     if (!$res) {
         return 0;
     } else {
         return 1;
     }
 }
开发者ID:YouthAndra,项目名称:huaitaoo2o,代码行数:26,代码来源:FileService.class.php

示例4: set_product_images_oxid

 /**
  * [set_product_images_oxid description]
  * @param [type] $product [description]
  */
 private function set_product_images_oxid($product)
 {
     global $oxid, $selectline;
     $product->images = $selectline['db']->get_results("SELECT * FROM " . $selectline['table_product_img'] . " WHERE [Blobkey] = 'AR" . $product->Artikelnummer . "'");
     if ($product->images) {
         $i = 1;
         $ftp = new Ftp();
         $ftp->connect($oxid['ftp_host']);
         $ftp->login($oxid['ftp_user'], $oxid['ftp_password']);
         foreach ($product->images as $image) {
             $img = WideImage::load($image->Bild);
             if ($i > 1) {
                 $filename = $product->ART_ID . '_' . $i . '.jpg';
             } else {
                 $filename = $product->ART_ID . '.jpg';
             }
             $img->saveToFile(ABSPATH . '/images/' . $filename);
             $ftp->put($oxid['img_path'] . '/master/product/' . $i . '/' . $filename, ABSPATH . '/images/' . $filename, FTP_BINARY);
             @unlink(ABSPATH . '/images/' . $filename);
             $oxid['db']->query($this->format_update_query($oxid['table_products'], array('OXPIC1' => $filename), array('OXID' => $product->ART_ID)));
             $i++;
         }
         $ftp->close();
     }
 }
开发者ID:baltruschat,项目名称:selectconnect,代码行数:29,代码来源:products.php

示例5: upload

 /**
  * Uploads a file or directory to an FTP connection.
  *
  * @param \Ftp         $ftp  An active FTP connection.
  * @param \SplFileInfo $file A local file to upload.
  */
 protected function upload(\Ftp $ftp, \SplFileInfo $file)
 {
     // enter into passive mode
     $ftp->pasv(true);
     // move to the file's parent directory
     $ftp->chdir($this->targetDirectory . '/' . $file->getRelativePath());
     // check if the file exists
     $fileExists = in_array($file->getBasename(), $ftp->nlist('.'));
     // check if the file is a directory
     if ($file->isDir()) {
         // create the directory if it does not exist
         if (!$fileExists) {
             $this->printTaskInfo('Creating directory: ' . $file->getRelativePathname());
             // create directory
             $ftp->mkdir($file->getBasename());
         }
     } else {
         // if the file already exists, check our skip options
         if ($fileExists) {
             // skip the file if the file sizes are equal
             if ($this->skipSizeEqual && $ftp->size($file->getBasename()) === $file->getSize()) {
                 return;
             }
             // skip the file if modified time is same or newer than source
             if ($this->skipUnmodified && $ftp->mdtm($file->getBasename()) >= $file->getMTime()) {
                 return;
             }
         }
         // try to upload the file
         $this->printTaskInfo('Uploading: ' . $file->getRelativePathname());
         if (!$ftp->put($file->getBasename(), $file->getRealpath(), FTP_BINARY)) {
             // something went wrong
             return Result::error($this, 'Failed while uploading file ' . $file->getRelativePathname());
         }
     }
 }
开发者ID:coderstephen,项目名称:robo-ftp,代码行数:42,代码来源:FtpDeployTask.php

示例6: do_create


//.........这里部分代码省略.........
        }
        // End Define Image Sizes
        // IF CREATIVE TYPE =1, ATTEMPT TO UPLOAD CREATIVE
        if ($data['creative_type'] == 1) {
            $creative_server = getconfig_var('default_creative_server');
            // Generate Creative Hash
            $uniqid = uniqid(time());
            $creative_hash = md5($uniqid);
            $file_extension = strtolower(substr(strrchr($_FILES['creative_file']['name'], "."), 1));
            // Case: Remote Creative Server (FTP)
            if (getconfig_var('default_creative_server') > 1) {
                list($width, $height, $type, $attr) = getimagesize($_FILES['creative_file']['tmp_name']);
                if ($height != $data['custom_creative_height'] or $width != $data['custom_creative_width'] or empty($file_extension)) {
                    global $errormessage;
                    $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload a valid image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . '';
                    global $editdata;
                    $editdata = $data;
                    return false;
                }
                $creative_server_detail = get_creativeserver_detail(getconfig_var('default_creative_server'));
                if ($creative_server_detail['entry_id'] < 1) {
                    global $errormessage;
                    $errormessage = 'The default creative server does not seem to exist. Please change your creative server in your mAdserve control panel under Configuration>Creative Servers';
                    global $editdata;
                    $editdata = $data;
                    return false;
                }
                // Attempt: Upload
                include MAD_PATH . '/modules/ftp/ftp.class.php';
                try {
                    $ftp = new Ftp();
                    $ftp->connect($creative_server_detail['remote_host']);
                    $ftp->login($creative_server_detail[remote_user], $creative_server_detail[remote_password]);
                    $ftp->put($creative_server_detail[remote_directory] . $creative_hash . '.' . $file_extension, $_FILES['creative_file']['tmp_name'], FTP_BINARY);
                } catch (FtpException $e) {
                    global $errormessage;
                    $errormessage = 'FTP Client was unable to upload creative to remote server. Error given: ' . $e->getMessage() . '';
                    global $editdata;
                    $editdata = $data;
                    return false;
                }
                // End: Upload
            }
            // End Case: Remote Creative Server (FTP)
            // Case: Local Creative Server
            if (getconfig_var('default_creative_server') == 1) {
                include MAD_PATH . '/modules/upload/class.upload.php';
                $handle = new Upload($_FILES['creative_file']);
                $handle->allowed = array('image/*');
                $handle->file_new_name_body = $creative_hash;
                if ($handle->uploaded) {
                    $image_width = $handle->image_src_x;
                    $image_height = $handle->image_src_y;
                    if (!empty($image_width) && !empty($image_height) && ($image_height != $data['custom_creative_height'] or $image_width != $data['custom_creative_width'])) {
                        global $errormessage;
                        $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload an image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . '';
                        global $editdata;
                        $editdata = $data;
                        return false;
                    }
                    $handle->Process(MAD_PATH . MAD_CREATIVE_DIR);
                    if ($handle->processed) {
                        // OK
                    } else {
                        global $errormessage;
                        $errormessage = 'Creative could not be uploaded. Please check if your creative directory is writeable (' . MAD_CREATIVE_DIR . ') and that you have uploaded a valid image file.';
开发者ID:aiurlano,项目名称:mAdserve-Fork,代码行数:67,代码来源:admin_functions.php


注:本文中的Ftp::put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。