|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5702 Inserting an uploaded JPEG file into Openldap
Submitted: 2000-07-20 16:48 UTC Modified: 2000-07-29 00:48 UTC
From: john dot hallam at compaq dot com Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.0.1pl2 OS: SuSE Linux 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: john dot hallam at compaq dot com
New email:
PHP Version: OS:


 [2000-07-20 16:48 UTC] john dot hallam at compaq dot com
I'm having trouble inserting a JPEG file into the jpegphoto attribute (Openldap 1.2.11).

From the documentation I have read I should be storing a base64 value in the jpegphoto attribute. I have managed to insert the photo with an ldap client and then made an LDIF extract to look at the base64 encoding. When I try to insert the jpegphoto with PHP, the base64 encoding is identical (I did an "echo" to print things on the screen) as to what I see with the LDIF extract. When I look at the openldap database I see totally different values than what I expect.

When I insert the jpegphoto with an LDAP client (LDAP Browser/Editor by Jarek Gawor - freeware) I can display the photo with the Netscape browser and I can see the base64 encoding correctly on the slapd server.

Here is the php code excerpt that shows you what I am doing :-

// Get the JPEG file. $AttributeValue is the JPEG file to upload

if ($Str_or_Bin == "binary") {
	if (!$file=fopen($AttributeValue, "r")) {
		print "<h3>Error: Upload of binary file failed</h3>";
else {
	$AttributeValue = chunk_split(base64_encode(fread($file,"$AttributeValue_size")));
// Insert JPEG file into LDAP database
// $AttributeValue contains the base64 encoding
// $AttributeName is jpegphoto
$info[$AttributeName] = $AttributeValue;
// Example of the echo printout after this code
echo "AND KNOW IT IS ".$info[$AttributeName]."<br><br><br>";
if ($ds) {
	@$r=ldap_bind($ds, $AdminDN, $Password);
	if ($r) {
		@$result = ldap_mod_add($ds, $PersonDN, $info);
		if ($result) {
			print '<h3>Addition Successful</h3>';
Here is what the 'echo "AND KNOW IT IS ".$info[$AttributeName]."<br><br><br>";' gives me


Is there a bug or am I doing something wrong ??

I've spent days trying to get it right/searching for an answer and I even upgraded from php3.0.14/openldap-1.2.10 so I'd be very grateful for any input.

Thanks & Regards
John, Compaq in Switzerland

PS php.ini has not been modified (eg. it's the same as php.ini-dist supplied with the php-4.0.1pl2) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-24 16:30 UTC]
Closed. See bug #5759 for reason.

 [2000-07-29 00:48 UTC]
Fixed in CVS. There is no need to base64_encode() that 
jpeg-file. Just read it into a variable as it is.

Please check bug #5759 for an example code.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 09:01:28 2024 UTC