PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 31, 2022

[FIXED] How to base64 encode a $_FILES file on a form post?

 July 31, 2022     file, file-upload, php     No comments   

Issue

How can I base64 encode a file sent from one page to another via a form POST.

The following do not work:

  • base64_encode($_FILES['file'])
  • base64_encode(file_get_contents($_FILES['file']))
  • base64_encode(file_get_contents($_FILES['file']['name']))

Why don't they work?

What is the correct thing to do to base64 encode the file?


Solution

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

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


Answered By - PHPDave
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing