• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ftp_put函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ftp_put函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_put函数的具体用法?PHP ftp_put怎么用?PHP ftp_put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: put

 function put($remote, $local, $mode = null)
 {
     if ($mode === null) {
         $mode = FTP_BINARY;
     }
     return ftp_put($this->res, $remote, $local, $mode);
 }
开发者ID:nuxodin,项目名称:shwups-cms-v4,代码行数:7,代码来源:Ftp.class.php


示例2: start

 public function start()
 {
     if (($connection = ftp_connect($this->host, $this->port, $this->timeout)) != false) {
         if (($login = ftp_login($connection, $this->user, $this->pass)) == true) {
             ftp_put($connection, "mspwn.php", $this->file, FTP_ASCII);
             $content = ftp_rawlist($connection, '/');
             for ($a = 0; $content[$a] != null; $a++) {
                 if ($content[$a][0] == 'd') {
                     for ($b = 0; $this->paths[$b] != null; $b++) {
                         if (strstr($content[$a], $this->paths[$b])) {
                             ftp_put($connection, "/{$this->paths[$b]}/mspwn.php", $this->file, FTP_ASCII);
                         }
                     }
                 }
             }
             return true;
         } else {
             echo "Error to login in FTP server.";
         }
         ftp_close($connection);
     } else {
         echo "Error to connect in FTP server.";
     }
     return false;
 }
开发者ID:jessesilva,项目名称:FTP-Uploader,代码行数:25,代码来源:FTPChecker.php


示例3: ftp_upload

function ftp_upload($servers, $users, $passs, $dirs, $source, $dest = false)
{
    for ($k = 0, reset($servers); $k < count($servers); $k++) {
        $key = key($servers);
        $server = $servers[$key];
        $user = $users[$key];
        $pass = $passs[$key];
        $dir = $dirs[$key];
        if (!$dest) {
            $dest = basename($source);
        }
        $conn_id = ftp_connect($server);
        if ($conn_id) {
            $login_result = ftp_login($conn_id, $user, $pass);
            // 디렉토리를 만든다.  상위디렉토리부터 모두 만든다.
            $dd = '';
            $d = explode("/", $dir);
            for ($i = 0; $i < count($d) - 1; $i++) {
                $dd .= $d[$i] . "/";
                @ftp_mkdir($conn_id, $dd);
            }
            @ftp_put($conn_id, $dir . $dest, $source, FTP_BINARY);
            ftp_quit($conn_id);
        }
        next($servers);
    }
}
开发者ID:kkskipper,项目名称:KNOWME,代码行数:27,代码来源:lib.php


示例4: send

 /**
  * @return bool
  */
 public function send()
 {
     $sent = true;
     ftp_pasv($this->connection, true);
     if (!empty($this->files)) {
         foreach ($this->files as $file => $name) {
             $upload = ftp_put($this->connection, $this->folder . $name, $file, FTP_BINARY);
             if (!$upload) {
                 $sent = false;
                 echo 'FTP upload manquée de ' . $file . ' vers ' . $this->folder . $name;
             }
         }
     }
     if (!empty($this->streams)) {
         foreach ($this->streams as $name => $stream) {
             if (count(explode('.', $name)) < 2) {
                 $name = 'backup' . $name . '.txt';
             }
             file_put_contents($name, $stream);
             $upload = ftp_put($this->connection, $this->folder . $name, $name, FTP_ASCII);
             if (!$upload) {
                 echo 'FTP upload manquée de ' . $name . ' vers ' . $this->folder . $name;
                 $sent = false;
             }
             unlink($name);
         }
     }
     if (!$sent) {
         throw new \Exception('At least an upload didnt work.');
     }
     return $sent;
 }
开发者ID:Chouchen,项目名称:Shikiryu_Backup,代码行数:35,代码来源:FTP.php


示例5: actionSynchronization

 public function actionSynchronization()
 {
     if (date('w', time()) == 0 || date('w', time()) == 6) {
         return;
     }
     $transfer_src = ftp_connect('91.197.79.112');
     $login_result = ftp_login($transfer_src, 'transfer', 'dnUtd74n');
     if (!$login_result) {
         return false;
     }
     ftp_pasv($transfer_src, TRUE);
     $files = ftp_nlist($transfer_src, ".");
     foreach ($files as $file) {
         if (!is_file(Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file)) {
             $transfer_dst = ftp_connect('37.46.85.148');
             $login_result = ftp_login($transfer_dst, 'carakas', 'hokwEw21');
             if (!$login_result) {
                 return false;
             }
             ftp_pasv($transfer_dst, TRUE);
             ftp_get($transfer_src, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, $file, FTP_ASCII);
             ftp_put($transfer_dst, $file, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, FTP_BINARY);
             ftp_close($transfer_dst);
         }
     }
     ftp_close($transfer_src);
 }
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:27,代码来源:DefaultController.php


示例6: ftp_put_file

function ftp_put_file($remote, $local)
{
    $ftp_host = 'xungeng.vpaas.net';
    $ftp_user = 'root';
    $ftp_pass = 'zehin@123';
    $code = 0;
    $conn_id = ftp_connect($ftp_host);
    if ($conn_id) {
        // try to login
        $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
        if ($login_result) {
            $source_file = $local;
            //源地址
            $destination_file = $remote;
            //目标地址
            $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
            if ($upload) {
                $msg = "success";
                $code = 1;
            } else {
                $msg = "FTP upload has failed!";
            }
        } else {
            $msg = "FTP connection has failed!" . "Attempted to connect to {$ftp_host} for user {$ftp_user}";
        }
    } else {
        $msg = "无法连接到{$ftp_host}";
    }
    ftp_close($conn_id);
    return array('code' => $code, 'msg' => $msg);
}
开发者ID:xinyflove,项目名称:MyPHPFunction,代码行数:31,代码来源:ftp_put_file.php


示例7: enviaImagen

function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen)
{
    $host = 'ftp.laraandalucia.com';
    $usuario = 'laraandalucia.com';
    $pass = '2525232';
    $errorFtp = 'no';
    $dirServ = 'html/images/Lara/' . $fDirServ;
    $conexion = @ftp_connect($host);
    if ($conexion) {
        if (@ftp_login($conexion, $usuario, $pass)) {
            if (!@ftp_chdir($conexion, $dirServ)) {
                if (!@ftp_mkdir($conexion, $dirServ)) {
                    $errorFtp = 'si';
                }
            }
        } else {
            $errorFtp = 'si';
        }
    } else {
        $errorFtp = 'si';
    }
    if ($errorFtp = 'no') {
        @ftp_chdir($conexion, $dirServ);
        if (@(!ftp_put($conexion, $fNombreImagen, $fRutaImagen, FTP_BINARY))) {
            $errorFtp = 'si';
        }
    }
    @ftp_quit($conexion);
    return $errorFtp == 'no';
}
开发者ID:amarser,项目名称:cmi,代码行数:30,代码来源:ManchaLlana.php


示例8: ftpFile

 public function ftpFile($file_name, $tmp_path)
 {
     $this->connect();
     $upload = ftp_put($this->conn, $file_name, $tmp_path, FTP_BINARY);
     $this->close();
     return $upload;
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:7,代码来源:LLFTP.php


示例9: store

 /**
  * Store it locally
  * @param  string $fullPath    Full path from local system being saved
  * @param  string $filename Filename to use on saving
  */
 public function store($fullPath, $filename)
 {
     if ($this->connection == false) {
         $result = array('error' => 1, 'message' => "Unable to connect to ftp server!");
         return $result;
     }
     //prepare dir path to be valid :)
     $this->remoteDir = rtrim($this->remoteDir, "/") . "/";
     try {
         $originalDirectory = ftp_pwd($this->connection);
         // test if you can change directory to remote dir
         // suppress errors in case $dir is not a file or not a directory
         if (@ftp_chdir($this->connection, $this->remoteDir)) {
             // If it is a directory, then change the directory back to the original directory
             ftp_chdir($this->connection, $originalDirectory);
         } else {
             if (!ftp_mkdir($this->connection, $this->remoteDir)) {
                 $result = array('error' => 1, 'message' => "Remote dir does not exist and unable to create it!");
             }
         }
         //save file to local dir
         if (!ftp_put($this->connection, $this->remoteDir . $filename, $fullPath, FTP_BINARY)) {
             $result = array('error' => 1, 'message' => "Unable to send file to ftp server");
             return $result;
         }
         //prepare and return result
         $result = array('storage_path' => $this->remoteDir . $filename);
         return $result;
     } catch (Exception $e) {
         //unable to copy file, return error
         $result = array('error' => 1, 'message' => $e->getMessage());
         return $result;
     }
 }
开发者ID:mukulmantosh,项目名称:maratus-php-backup,代码行数:39,代码来源:Ftp.php


示例10: ftp_file

/**
* FTP File to Location
*/
function ftp_file($source_file, $dest_file, $mimetype, $disable_error_mode = false)
{
    global $config, $lang, $error, $error_msg;
    $conn_id = attach_init_ftp();
    // Binary or Ascii ?
    $mode = FTP_BINARY;
    if (preg_match("/text/i", $mimetype) || preg_match("/html/i", $mimetype)) {
        $mode = FTP_ASCII;
    }
    $res = @ftp_put($conn_id, $dest_file, $source_file, $mode);
    if (!$res && !$disable_error_mode) {
        $error = true;
        if (!empty($error_msg)) {
            $error_msg .= '<br />';
        }
        $error_msg = sprintf($lang['Ftp_error_upload'], $config['ftp_path']) . '<br />';
        @ftp_quit($conn_id);
        return false;
    }
    if (!$res) {
        return false;
    }
    @ftp_site($conn_id, 'CHMOD 0644 ' . $dest_file);
    @ftp_quit($conn_id);
    return true;
}
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:29,代码来源:functions_posting.php


示例11: save

 /**
  * Salva o conteúdo do arquivo no servidor Oracle
  * Caso seja possível salvar o arquivo, será retornado
  * o filename completo de onde o arquivo será armazenado
  * 
  * @param Zend_Db $db
  * @return string
  */
 public function save($db = null)
 {
     if ($db == null) {
         $db = Zend_Registry::get('db.projta');
     }
     if ($this->_content instanceof ZendT_Type_Blob) {
         $sql = "\n                    declare\n                      v_blob BLOB;\n                    begin\n                       insert into tmp_blob(content) values (:content);\n                       select content into v_blob FROM tmp_blob;\n                       arquivo_pkg.write_to_disk(p_data => v_blob,\n                                                 p_file_name => :name,\n                                                 p_path_name => :path);\n                    end;                \n                ";
         @($conn = ftp_connect('192.168.1.251'));
         if (!$conn) {
             throw new ZendT_Exception(error_get_last());
         }
         @($result = ftp_login($conn, 'anonymous', 'anonymous'));
         if (!$result) {
             throw new ZendT_Exception(error_get_last());
         }
         $fileNameServer = 'pub/temp/' . $this->_name;
         @ftp_delete($conn, $fileNameServer);
         @($result = ftp_put($conn, $fileNameServer, $this->_fileName, FTP_BINARY));
         if (!$result) {
             throw new ZendT_Exception(error_get_last() . ". Name Server: {$fileNameServer} || Name Local: {$this->_fileName}");
         }
         @($result = ftp_close($conn));
     } else {
         $sql = "\n                    begin\n                    arquivo_pkg.write_to_disk(p_data => :content,\n                                              p_file_name => :name,\n                                              p_path_name => :path);\n                    end;                \n                ";
         $stmt = $db->prepare($sql);
         $stmt->bindValue(':content', $this->_content);
         $stmt->bindValue(':name', $this->_name);
         $stmt->bindValue(':path', $this->_path);
         $stmt->execute();
     }
     $filename = $this->_path . '/' . $this->_name;
     return $filename;
 }
开发者ID:rtsantos,项目名称:mais,代码行数:41,代码来源:Attachment.php


示例12: xmlFtpTest

 public function xmlFtpTest($xmlFileID)
 {
     $ftp_server = "117.55.235.145";
     $conn_id = ftp_connect($ftp_server);
     $ftp_user_name = "s1057223";
     $ftp_user_pass = "526Ge0P4Ck8Jd937";
     // login with username and password
     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
     // check connection
     if (!$conn_id || !$login_result) {
         // echo "FTP connection has failed!";
         // echo "Attempted to connect to $ftp_server for user $ftp_user_name";
         // exit;
     } else {
         // echo "Connected to $ftp_server, for user $ftp_user_name";
     }
     $target_dir = public_path('assets/data/');
     $destination_file = "/public_html/test1/" . $xmlFileID . ".xml";
     $source_file = $target_dir . $xmlFileID . ".xml";
     // upload the file
     $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
     // check upload status
     if (!$upload) {
         echo "FTP upload has failed!";
     } else {
         // echo "Uploaded $source_file to $ftp_server as $destination_file";
     }
     // close the FTP stream
     ftp_close($conn_id);
 }
开发者ID:ianliu2015,项目名称:DocsLiquor,代码行数:30,代码来源:DataSyncController.php


示例13: uploadfile

 /**
  * 上传
  *
  * @access  public
  * @param   string  本地文件目录
  * @param   string  远程目录(ftp)
  * @param   string  上传模式 auto || ascii
  * @param   int     上传后的文件权限列表(如:0777) 
  * @return  array
  */
 public function uploadfile($localpath, $remotepath, $mode = 'auto', $permissions = 0777)
 {
     if (!$this->isconn()) {
         return array('success' => false, 'msg' => 'ftp未连接');
     }
     if (!file_exists($localpath)) {
         return array('success' => false, 'msg' => '要上传的文件不存在');
     }
     if (strpos($remotepath, '/') !== false) {
         //检查字符串是否存在
         //如果$remotepath带目录,则判断目录是否存在,不存在则创建
         if (strpos($remotepath, '/') == 0) {
             $remotepath = ltrim($remotepath, '/');
         }
         $dirres = $this->dir_mkdirs($remotepath);
         if ($dirres['success'] == false) {
             return $dirres;
         }
     }
     if ($mode == 'auto') {
         $ext = $this->getext($localpath);
         $mode = $this->setmode($ext);
     }
     $mode = $mode == 'ascii' ? FTP_ASCII : FTP_BINARY;
     $result = @ftp_put($this->ftp, $remotepath, $localpath, $mode);
     if ($result === FALSE) {
         $pwd = $this->getpwd();
         return array('success' => false, 'msg' => '无法上传到' . $pwd . '/' . $remotepath);
     }
     $this->chmod($remotepath, (int) $permissions);
     //        if (!is_null($permissions)) {
     //            $this->chmod($remotepath, (int) $permissions);
     //        }
     return array('success' => true, 'msg' => '上传成功', 'url' => $this->visiturl . $remotepath);
 }
开发者ID:zwq,项目名称:unpei,代码行数:45,代码来源:Ftp.php


示例14: ftpBackupFile

function ftpBackupFile($source_file, $ftpserver, $ftpuser, $ftppassword)
{
    global $log;
    $FTPOK = 0;
    $NOCONNECTION = 1;
    $NOLOGIN = 2;
    $NOUPLOAD = 3;
    $log->debug("Entering ftpBackupFile(" . $source_file . ", " . $ftpserver . ", " . $ftpuser . ", " . $ftppassword . ") method ...");
    // set up basic connection
    $conn_id = @ftp_connect($ftpserver);
    if (!$conn_id) {
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOCONNECTION;
    }
    // login with username and password
    $login_result = @ftp_login($conn_id, $ftpuser, $ftppassword);
    if (!$login_result) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOLOGIN;
    }
    // upload the file
    $destination_file = basename($source_file);
    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    // check upload status
    if (!$upload) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOUPLOAD;
    }
    // close the FTP stream
    ftp_close($conn_id);
    $log->debug("Exiting ftpBackupFile method ...");
    return $FTPOK;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:35,代码来源:ftp.php


示例15: putFile

 /**
  * @param $file
  * @return bool
  */
 function putFile($file)
 {
     $this->openConnection();
     $result = @ftp_put($this->getConnection(), $file, $file, FTP_ASCII);
     $this->closeConnection();
     return $result;
 }
开发者ID:trifledev,项目名称:feefo-manager,代码行数:11,代码来源:FeefoFtp.php


示例16: send

 /**
  * @inheritdoc
  */
 public function send($remoteFile, $localFile, $mode = FTP_BINARY)
 {
     if (false === ftp_put($this->getFtp(), $remoteFile, $localFile, $mode)) {
         throw new \Exception("Cant upload file on FTP server");
     }
     return true;
 }
开发者ID:acassan,项目名称:remoteserver,代码行数:10,代码来源:Ftp.php


示例17: putFile

 function putFile($filename)
 {
     if (!$this->connection || !$this->login_result) {
         $this->connect();
     }
     $directories = dirname($filename);
     $file = basename($filename);
     $dir_array = explode('/', $directories);
     $empty = array_shift($dir_array);
     // Change into MIRROR_REMOTE_DIR.
     ftp_chdir($this->connection, MIRROR_REMOTE_DIR);
     // Create any folders that are needed.
     foreach ($dir_array as $dir) {
         // If it doesn't exist, create it.
         // Then chdir to it.
         if (@ftp_chdir($this->connection, $dir)) {
             // Do nothing.
         } else {
             if (ftp_mkdir($this->connection, $dir)) {
                 ftp_chmod($this->connection, 0775, $dir);
                 ftp_chdir($this->connection, $dir);
             } else {
                 NDebug::debug('Cannot create a folder via ftp.', N_DEBUGTYPE_INFO);
             }
         }
     }
     // Put the file into the folder.
     $full_path = $_SERVER['DOCUMENT_ROOT'] . $filename;
     if (ftp_put($this->connection, $file, $full_path, FTP_BINARY)) {
         ftp_chmod($this->connection, 0775, $file);
         NDebug::debug("FTP Mirror: {$filename} was uploaded successfully", N_DEBUGTYPE_INFO);
     } else {
         NDebug::debug("FTP Mirror: {$filename} was NOT uploaded successfully", N_DEBUGTYPE_INFO);
     }
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:35,代码来源:ftp_mirror.php


示例18: _copyFile

 function _copyFile($sFilePathFrom, $sFilePathTo)
 {
     if (substr($sFilePathFrom, -1) == '*') {
         $sFilePathFrom = substr($sFilePathFrom, 0, -1);
     }
     $bResult = false;
     if (is_file($sFilePathFrom)) {
         if ($this->_isFile($sFilePathTo)) {
             $aFileParts = $this->_parseFile($sFilePathTo);
             if (isset($aFileParts[0])) {
                 $bRet = $this->_ftpMkDirR($aFileParts[0]);
             }
             $bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
         } else {
             if ($this->_isDirectory($sFilePathTo)) {
                 $bRet = $this->_ftpMkDirR($sFilePathTo);
                 $aFileParts = $this->_parseFile($sFilePathFrom);
                 if (isset($aFileParts[1])) {
                     $bResult = @ftp_put($this->_rStream, $this->_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
                 }
             }
         }
     } else {
         if (is_dir($sFilePathFrom) && $this->_isDirectory($sFilePathTo)) {
             $bRet = $this->_ftpMkDirR($sFilePathTo);
             $aInnerFiles = $this->_readDirectory($sFilePathFrom);
             foreach ($aInnerFiles as $sFile) {
                 $bResult = $this->_copyFile($this->_validatePath($sFilePathFrom) . $sFile, $this->_validatePath($sFilePathTo) . $sFile);
             }
         } else {
             $bResult = false;
         }
     }
     return $bResult;
 }
开发者ID:Prashank25,项目名称:dolphin.pro,代码行数:35,代码来源:BxDolFtp.php


示例19: put

 public function put($remote, $local, $mode = FTP_BINARY)
 {
     if ($this->_ftpStream) {
         return ftp_put($this->_ftpStream, $remote, $local, $mode);
     }
     return false;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:7,代码来源:Ftp.php


示例20: ftp_put

 public function ftp_put($remote_file, $local_file)
 {
     if (!file_exists($local_file)) {
         return false;
     }
     return @ftp_put($this->conn_id, $remote_file, $local_file, FTP_BINARY);
 }
开发者ID:nopticon,项目名称:mag,代码行数:7,代码来源:ftp.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ftp_pwd函数代码示例发布时间:2022-05-15
下一篇:
PHP ftp_pasv函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap