我正在将图像上传转换为base64,但我也试图不必将图像存储在我的服务器上不幸的是,这段代码将文件存储在我的服务器上是否有办法让它在编码后删除文件到基数64?
这是我的代码..
if(isset($_FILES['t1']['name'])){
$file = rand(0, 10000000).$_FILES['t1']['name'];
if (move_uploaded_file($_FILES['t1']['tmp_name'], $file)) {
if($fp = fopen($file,"rb", 0))
{
$picture = fread($fp,filesize($file));
fclose($fp);
// base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics
$base64 = base64_encode($picture);
$tag1 = '<img src="data:image/png;base64,'.$base64.'" alt="" />';
$css = 'url(data:image/png;base64,'.str_replace("\n", "", $base64).'); ';
}
}
}