PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How can i pass the namefmt parameter in a php ftp connection?

 August 01, 2022     ftp, ibm-midrange, php     No comments   

Issue

I need to connect via FTP to an as400 server. The connection necessarily requires the NAMEFMT parameter to write. How is it possible to insert the parameter in php ftp connection code?

Thanks


Solution

use ftp_site to send the namefmt command.

$ftp = ftp_connect('serverurl.com');
ftp_login($ftp, 'user', 'pass');
ftp_site( $ftp, "namefmt 1");
ftp_chdir( $ftp, "/home/steve");

// get contents of the current directory
$contents = ftp_nlist($ftp, ".");

// write directory listing to stdout
echo "<pre>";
foreach( $contents as $item )
{
  echo "$item\n";
}
echo "</pre>";

// change namefmt to 0.
ftp_chdir( $ftp, "/qsys.lib/qgpl.lib");
ftp_site( $ftp, "namefmt 0");

// get srcmbr named PROOF in QGPL/QRPGLESRC
echo "<pre>";
$result = ftp_get($ftp, "php://output", "qgpl/qrpglesrc.proof", FTP_ASCII );
echo "</pre>" ;
ftp_close( $ftp ) ;



Answered By - RockBoro
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing