fread formatting issue :-)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adam:-)
Forum Newbie
Posts: 1
Joined: Tue Mar 09, 2004 1:16 pm

fread formatting issue :-)

Post by adam:-) »

hello everyone =)
I am having a problem with fread messing up the spacing format of my file. What I am trying to do is tar a directory, which is working fine and then read that directory into a string using fread then base64 encoding it and send it back as a string which will be decoded on their side and saved as a .tar file which in turn will be unzipped and reveal the directory. The problem is that after I read it in and send it I rename it to blah.tar and it says that it wont open? I look at it with a text editor and all the data is correct, but it seems the only issue is that the formatting of the data is not the same as the formatting of the tar that is on the server. (it doesnt seem to be preserving spaces. SO does anyone know what might be causing this?

if(getone("select * from system_register where system_id = '".$authenticate["system_id"]."' AND system_pass = '".$authenticate["pass_id"]."'")){
exec("tar -cf cdmi.tar CDMI_DATA");
$file = "cdmi.tar";
$file_data = '';
$fh = fopen($file,"rb");
$file_data = fread($fh, filesize($file));
$file_data = base64_encode($file_data);
fclose($fh);
$usage_data = array('usage_data'=>$file_data);
}else{
$usage_data = array('usage_data'=>'error : invalid authentication');
}
return $usage_data;

Thankyou so much for you time :-)

Adam
Post Reply