binmode INBIN; my $n_bytes = read(INBIN, $buff, $BUFSIZE); #### use MIME::Base64; use strict; use warnings; my $upload_dir = 'uploaded_files'; my $file_name = 'image.jpg'; ### Open the image to convert to base64 open (IMAGE, '<', "$upload_dir/$file_name") or die "$!"; binmode IMAGE; my $binary = ; my $base64 = encode_base64(pack('B*', $binary)); print "base64 = $base64\n";