phpseclib enableDatePreservation not preserving date - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, June 11, 2021

phpseclib enableDatePreservation not preserving date

Maybe somebody out here may have encountered this issue before. I am using phpseclib version 3.

My code is basically uploading a file via SFTP to another server. The connection part is good, and the upload also pushes through.

However, I need to maintain the date modified for the uploaded file. Currently the files uploaded get the time they are uploaded as the date modified.

require_once __DIR__ . '/vendor/autoload.php';
use phpseclib3\Net\SFTP;

$server = "xxx.com";
$username = "xxxx";
$password = "xxxxxx";

$sftp = new SFTP($server);
$sftp->enableDatePreservation();

if($sftp->login($username, $password)){

$test1 = $sftp->put("public_html/Content/". basename($filename), $filename, SFTP::SOURCE_LOCAL_FILE);

if ($test1) { echo "upload ok"; } else { echo "not ok"; }

Note that this is just rough code, just proof of concept at this point. Just trying to get the file modified date/time to transfer over. I also tried adding the enableDatePreservation AFTER the $sftp-put. I also tried uploading to different servers, just in case it is a user permission problem. same result.

Hopefully someone out there has some insights! Thanks a lot!



source https://stackoverflow.com/questions/67926723/phpseclib-enabledatepreservation-not-preserving-date

No comments:

Post a Comment