473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Going crazy about binary post

Hey all,

I'm tearing my hair out over this one.. I'm using EasyPHP, and trying to
write a script which receives binary POST data from a client program of
mine. I've put together a simplified example which demonstrates the
problem. The data looks like this:

(String showing the length of the following binary)(Character
#10)(Binary data)

My PHP script looks like this:

<?
include('databasedef.php');
set_magic_quotes_runtime(0);
$chandle = mysql_pconnect($servername, $username, $password) or
die("FAIL");
mysql_select_db($database, $chandle) or die ("FAIL");

$handle=fopen("php://input","rb") or die("FAIL");

$c=fgets($handle,20);

$picture=mysql_real_escape_string(fread($handle,$c ));

$query="INSERT INTO ".$table." (Picture) VALUES ('".$picture."')";
mysql_db_query($database, $query) or die("Failed Query");

fclose($handle);
mysql_close($chandle);
?>

Although I get the right number of bytes in my MySQL database, they're
corrupted! What setting am I missing here? The files being stored are
less than 40k in a MEDIUMBLOB field.

Cheers,
Nicholas Sherlock
Jul 17 '05 #1
2 1450
Puzzling. It might have something to do with the
encoding. What kind of files are you inserting?

More likely, though, it is a bug specific to
EasyPHP, perhaps due to compilation issues.
Can you try running your code on a Linux box?

Felix

Jul 17 '05 #2
Felix wrote:
Puzzling. It might have something to do with the
encoding. What kind of files are you inserting?
GIF images. It's got me beat as well.
More likely, though, it is a bug specific to
EasyPHP, perhaps due to compilation issues.
Can you try running your code on a Linux box?


I don't have one available.. I'll try updating the individual components
of EasyPHP.

Cheers,
Nicholas Sherlock
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
0
by: Jay Douglas | last post by:
I am trying to do an HTTP POST to a webpage from a DLL. The webpage is easily called, and a response is given. However, the web page is not receiving the POSTed variables. None of them. ...
3
by: Navin | last post by:
Hello friends... On a single asp.net web page i have a single server-side form that contains a couple of user-controls. Each user control has its own functionality and contains server-side textbox...
1
by: Merlin | last post by:
Hi Again Group, Sorry to trouble you all again but i`ve been looking at this problem for 2 weeks now and just don`t seem to be able to grasp how to create a relationship in VB.NET with ADO.NET....
37
by: Zhiv Kurilka | last post by:
Hi, I have a text file with following content: "((^)|(.* +))§§§§§§§§" if I read it with: k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII); k.readtotheend()
11
by: shapper | last post by:
Hello, I am creating a centered web site with various div's inside the main (pBase) div. Somehow, I am getting a gap on the top of my browser window both in IE and Firefox. I tried...
10
by: shapper | last post by:
Hello, I have a custom control under namespace MyNameSpace.WebControls with a property of type validation: ' Validation Private _Validation As Validation < _ Bindable(True), _...
1
by: shapper | last post by:
Hi, On a form I have an input where tags are inserted in a CSV format. Then on my code I convert the CSV string to a List<Tag>. Tag is an object with two properties: TagID and Name So when I...
1
by: shapper | last post by:
Hello, On my CMS I am signed as administrator and I am creating a Membership user and its profile: MembershipCreateStatus status; MembershipUser user = Membership.CreateUser("Joe", "Pass",...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.