Creating a file from php://input

Hello guys,

I’m pretty new to php and I have a problem with the functionality of a script I’ve wrote.

The script looks something like this:
[php]

<?php $data = file_get_contents('php://input'); $data = str_replace('content-type: application/vnd.ms-excel;name="Mappe1.xls"','',$data); $data = trim($data); $fp = fopen("file.xls", 'ab'); if ($fp){ fwrite($fp,$data); fclose($fp); echo 'Data written ok to file'; } ?>

[/php]

Now the user (which is actually a SAP client) sends to this script the following post content:

content-type: application/vnd.ms-excel;name="Mappe1.xls"

BINARY DATA HERE -- looks something like ÐÏࡱá>þÿ

--SAP

The problem is the file is unusable when I get it through this script.
Any kind of help would be appreciated.

Thank you,
Ciprian

XLS is not a text file you will need a reader parser for it
You can try the one below or find another

Sponsor our Newsletter | Privacy Policy | Terms of Service