如何将文件名传递给ftp_put函数?

It's a simple code to resize an image and send it to ftp server:

$info = getimagesize($_FILES["personalPhoto"]["tmp_name"]);
$image = imagecreatefromjpeg($_FILES["personalPhoto"]["tmp_name"]);
ob_start();
imagejpeg($image,null, 1);
$resizedImage = ob_get_contents();
ob_end_clean();   


ftp_put($ftpConn,'/Kamil/HostMe/AllImages/'.$fileName.'.jpg',$_FILES["personalPhoto"]["tmp_name"],FTP_BINARY);

ftp_put($ftpConn,'/Kamil/HostMe/AllImages/'.$fileName.'.jpg',$resizedImage,FTP_BINARY);

The first ftp_put command works fine (sends the original image to server)

the second ftp_put command which is supposed to send the resized image is not working. any ideas?

$resizedImage is a PHP variable, not a physical file. To solve your problem, you can write $resizedImage into a file then set this to ftp_put. Such as:

$file = "/tmp/somefile.jpg";
file_put_contents($file, $resizedImage);
ftp_put(
  $ftpConn,
  '/Kamil/HostMe/AllImages/'.$fileName.'.jpg',
  $file,
  FTP_BINARY
);