Current location: Hot Scripts Forums » Programming Languages » PHP » base64_decode an image, works on blank page, not on page where text is..


base64_decode an image, works on blank page, not on page where text is..

Reply
  #1 (permalink)  
Old 08-09-04, 05:07 AM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
base64_decode an image, works on blank page, not on page where text is..

if I try to base64_decode an image which was encoded with base64_encode on a blank page, it works, if I try on a page with stuff already on it, it just shows me the source code to the image...

Example: Run this code as a blank page, no spaces before or after the <?
then run it again with a space or a character..

Any ideas how to fix it?
Thanks.
PHP Code:

<?php

if (!function_exists("ac_call_base64_image")) {
    function 
ac_call_base64_image ($Image) {
        
//require ("./ACWB/ACWB_Base64_Images.php");
        //$Image = $ACWB_B64I[$Image];
        
return base64_decode($Image);
    }
}
// RedX Image...
$ACWB_B64I['ACWB'] = "R0lGODlhHAAeAKIAAP8AAP///8DAwICAgAAAAP///wAAAAAAACH5BAEAAAUALAAAAAAcAB4AAAOCOLrc7mGUSau9NuLNp+5g9YXhSHbmuaXF81zsEMx0HQgELFmybeO6S89HA2Z2lSHxljsKaQDALDozipAUZZRabV6fNW43yAtvi15KDCoNcK1q7ERJhHvkrSWanNSPnWV+dgUxAoaHiIZpdxcEjo+QkHwqK3iUX5eVmZqbk50efqFECQA7";
echo 
ac_call_base64_image ($ACWB_B64I['ACWB']);
?>
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #2 (permalink)  
Old 08-09-04, 08:47 AM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
unless you explicitly declare header after decoding your image, what you'll find is only normally parsed php script. note that even a space has told php that it should sent text/html header.
__________________
Useful PHP links:
bugs.php.net - for reporting PHP bugs
pear.php.net - PHP extension and application repository
pecl.php.net - get non standard PHP modules, submit yours
www.phpclasses.org - PHP classes repository
Reply With Quote
  #3 (permalink)  
Old 08-09-04, 01:16 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah, but the thing is, even with headers..

I try calling that function from a different page, and it shows up as the source to the image..
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
how to change text dynamically with image? rabbit51 JavaScript 1 02-23-04 08:35 AM
How to change text dynamically with image? rabbit51 Script Requests 0 02-07-04 12:14 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 04:18 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.