如何基于64编码$ _POST $ _FILES文件

I want to know how I can base64 encode a file that is being sent from one page to another on APOST form.

Because,this doesn't work base64_encode($_FILES['file']) or even base64_encode(file_get_contents($_FILES['file'])). or even base64_encode(file_get_contents($_FILES['file']['name'])).

Why don't they work.What is the correct thing to do.

tmp_name is the file path to the file that is being temporarily stored

base64_encode(file_get_contents($_FILES['file']['tmp_name']))