this is my code to get image from song but it does not working.
<?php
include('getID3-master/getid3/getid3.php');
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$ip=get_client_ip();
if(!empty($_FILES)){
$targetDir =get_template_directory_uri()."/uploads/";
$fileName = $_FILES['file']['name'];
$fileName = str_replace(' ','', $fileName);
$targetFile = $targetDir.$fileName;
$user_id=get_current_user_id();
$target = get_template_directory()."/uploads/".$fileName;
if(move_uploaded_file($_FILES['file']['tmp_name'],$target)){
$Path=$target;
$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($Path);
if(isset($OldThisFileInfo['comments']['picture'][0])){
$Image='data:'.$OldThisFileInfo['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($OldThisFileInfo['comments']['picture'][0]['data']);
}
if(get_current_user_id())
{
$data=array(
'file_name' => $fileName,
'uploaded' => date("Y-m-d H:i:s"),
'user_id' => $user_id,
'user_ip' => $ip,
'image' =>$Image
);
}else{
$data=array(
'file_name' => $fileName,
'uploaded' => date("Y-m-d H:i:s"),
'user_id' => 0,
'user_ip' => $ip,
'image' =>$Image
);
}
$wpdb->insert( 'files', $data);
}
}
?>
I think there is a problem with the file path.but not sure please help.