PHP convert file to string

Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery

Here is solution how easily you can convert any file into string

For web development if web developer want to store file contents or transfer file contents, In php the file can easily converted to string and vice versa.

Using Base64 encode

$filepath="full file path"; // example c:\images\mypic.jpg

$fileString=base64_encode(addslashes(fread(fopen($filepath, "r"), filesize($filepath))));

Using Base64 Decode


$fp = fopen('newFileName', 'w');
fwrite($fp, $decodedData);

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

No comments:

Post a Comment