Hey, I want to upload an image and it to also base 64 encode it for back up. I am using: <?php $rand = rand(); $target = '/home/example/public_html/images/small/'.$rand.'_' . basename( $_FILES['uploaded1']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded1']['tmp_name'], $target)) {$img_1 = 'yes';} else {$img_1 = 'no';} $img1_url = $target; $img1_url = str_replace('/home/example/public_html/images/small/','http://example.com/images/small/',$img1_url);/*Replace Space With -*/ ?> PHP: I need it to echo the base64 code so it can be used a back.
$encodedImg = base64_encode(imagecreatefromgif($img1_url)); echo($encodedImg); PHP: Something like that should work. Then if you want to use it in HTML you must change the <img src> to echo '<img src="data:image/gif;base64,'.$encodedImg.' ">'; PHP:
Hi What problem you are facing? You are not able to upload the image or not able to encode in base 64.