I am having a problem when I am sending a pdf file to my server.

my script works when I try to send .csv file but the problem occurs when I try to send a pdf file

$user= "username";
$pass= "password";
$src= "/home/desktop/myfile.pdf";
$trg= "/server/path/myfile.pdf";

$con = ssh2_connect('myserver.com', 22);
ssh2_auth_password($con, $user, $pass);

ssh2_scp_send($con, $src, $trg);
when I send pdf. it creates a pdf file in target location but its corrupted.