本文整理汇总了PHP中ftp_put函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_put函数的具体用法?PHP ftp_put怎么用?PHP ftp_put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_put函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
function put($remote, $local, $mode = null)
{
if ($mode === null) {
$mode = FTP_BINARY;
}
return ftp_put($this->res, $remote, $local, $mode);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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';
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例15: putFile
/**
* @param $file
* @return bool
*/
function putFile($file)
{
$this->openConnection();
$result = @ftp_put($this->getConnection(), $file, $file, FTP_ASCII);
$this->closeConnection();
return $result;
}