By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

File Upload and conversion not working

P: n/a
Hello,

I just got a client that is running their PHP site on Apache 1.3 with
PHP 4.x. The server is very weak and during peak times hangs. I am not
a programmer, so having a little dificulty figuring these out....

I am in a process of moving it over to another server, however running
into a few things:

1. One of the links is to upload your own logo in a BMP format and the
other is to convert BMP to WBMP. Neither one of those work and the
page just gets refreshed and nothing happens.... Below is the code for
this page.... Is there something I need to turn on in the php.ini file
or soething similar? Based on the code I see below, it seems like its
not hitting any of the "case" statements. Is there anyway I can turn
on tracing for PHP? (see code below)

2. The PNG files would not get generated - figured out that I needed
freetype and ttf support...., however the PNG files that get generated
now are empty with no data - I think I can figure this one out once i
dig down into the code....

----------------Begin Code---------------------------
<?

function traite_err($err,$var)
{
include("home.php"); ?>
<table bgcellpadding=0 cellspacing=0 border=0 width="100%">
<tr>
<td align="left" valign="top"><? include("sommaire.php"); ?></td>
<td><img src="img/20pix.gif" border=0></td>
<td width="100%" valign="top" align="left">
<? echo "<br><br><img border=\"0\" src=\"img/bmp2wbmp.gif\"
width=\"346\" height=\"22\" border=\"0\">\
n";
echo "<BR>\n";
echo "<TABLE border=0 cellPadding=3 cellSpacing=0>\n";

switch($err)
{
case 1:
echo "<TR><TD align=\"left\"
valign=\"middle\">";
echo "<IMG SRC=\"img/notchecked.gif\"
height=\"34\" width=\"34\">\n";
echo "Not a bitmap file(.bmp)\n";
echo "<BR><A
HREF=\"index2.php3?disp=bmp2wbmp\"><img src=\"img/retour.gif\" border=
0></A>\n";
echo
"</TD></TR></TABLE></td></tr></table></BODY></HTML>";
exit;
break;

case 2:

echo "<TR><TD align=\"left\"
valign=\"middle\">";
echo "<IMG SRC=\"img/notchecked.gif\"
height=\"34\" width=\"34\">\n";
echo "File is too big (>2K) ($f_size
octets)\n";
echo "<BR><A
HREF=\"index2.php3?disp=bmp2wbmp\"><img src=\"img/retour.gif\" border=
0></A>\n";
echo
"</TD></TR></TABLE></td></tr></table></BODY></HTML>";
exit;

break;

case 3:

echo "<TR><TD>\n";
echo "<i>This file is not in BMP
format</i>\n";
echo "<BR><A
HREF=\"index2.php3?disp=bmp2wbmp\"><img src=\"img/retour.gif\" border=
0></A>\n";
echo
"</TD></TR></TABLE></td></tr></table></BODY></HTML>";
exit;

break;

case 4:

echo "<TR><TD>\n";
echo "<i>Two colors depth images only (black
and white)</i>\n";
echo "<BR><A
HREF=\"index2.php3?disp=bmp2wbmp\"><img src=\"img/retour.gif\" border=
0></A>\n";
echo
"</TD></TR></TABLE></td></tr></table></BODY></HTML>";
exit;

break;

case 5:

echo "<TR><TD>\n";
echo "<i>Image width must be a multiple of 32
pixels (32,64,96)</i><br>This image w
idth is $var pixels<br>\n";
echo "</TD></TR>\n";

break;

case 6:

echo "<TR><TD>\n";
echo "<i>Image height must be less than 127
pixels</i>\n";
echo "</TD></TR>\n";
break;

}
echo "<TR><TD>\n";
echo "<BR><A HREF=\"index2.php3?disp=bmp2wbmp\"><img
src=\"img/retour.gif\" border=0></A>\n";
echo "</TD></TR>\n";
echo "</TABLE></td></tr></table></BODY></HTML>";
exit;
}
if ((isset($users_file))&&($users_file!="none")) {

$fname=$users_file_name;
if ((strstr($users_file_name,".bmp")!=".bmp")&&(strst r($users_file_name,".BMP")!=".BMP"))
{
traite_err(1,0);
}

$fname=substr($fname,0,strpos($fname,".bmp"));

$outfname=$fname.".wbmp";
$f_size=filesize($users_file);
if ($f_size>2000)
{
traite_err(2,0);
}
$aabenFil = fopen($users_file, "r");
$filindhold = fread($aabenFil, filesize($users_file));

$B=$filindhold[0];
$M=$filindhold[1];
$bfsize=ord($filindhold[2])+ 256 * ord($filindhold[3]);
$bfOffBits=ord($filindhold[10])+ 256 * ord($filindhold[11]);
$largeur=ord($filindhold[18]) + 256 * ord($filindhold[19]);
$hauteur=ord($filindhold[22]) + 256 * ord($filindhold[23]);
$bfBitCount=ord($filindhold[28]) + 256 * ord($filindhold[29]);
$err=0;
$mult=$largeur % 32;
if (($B!="B")||($M!="M"))
{
traite_err(3,0);
}

if ($bfBitCount!=1)
{
traite_err(4,0);

}


if ($mult!=0)
{
traite_err(5,$largeur);
}

if ($hauteur>127)
{
traite_err(6,0);
}

$j=0;

$nbcharlarg=$largeur/8;

$numline=0;

for($i=0;$i<filesize($users_file)-62;$i++)
{

if (($i % $nbcharlarg)==0)
{
$numline++;
$line[$numline]="";
}

if ($inverse=="on")
$line[$numline].=$filindhold[$i+62];
else

$line[$numline].=chr(255-ord($filindhold[$i+62]));

$count++;
}

//Header( "Content-Disposition: attachment;
filename=".$outfname );
Header( "Content-Disposition: filename=".$outfname );
Header("Content-type: image/vnd.wap.wbmp");
header( "Content-Description: ".$outfname );

echo chr(0);
echo chr(0);
echo chr($largeur);
echo chr($hauteur);
for($i=$hauteur;$i>0;$i--)
{
echo $line[$i];
}
exit;
}
else {
include("home.php"); ?>
<table bgcellpadding=0 cellspacing=0 border=0 width="100%">
<tr>
<td align="left" valign="top"><? include("sommaire.php"); ?></td>
<td><img src="img/20pix.gif" border=0></td>
<td width="100%" valign="top" align="left"><?
echo "<br><br><img border=\"0\" src=\"img/bmp2wbmp.gif\" width=\"346\"
height=\"22\" border=\"0\">\n";
echo "<FORM ACTION=\"index2.php3?disp=bmp2wbmp\"
ENCTYPE=\"multipart/form-data\" METHOD=\"post\">\n";
echo "<FONT size=2 color=\"#003366\" face=\"Verdana, Arial, Helvetica,
sans-serif\">Source file is a 2 colo
rs windows Bitmap (black and white .bmp)<br>
32,64 or 92 pixels width and up to 127 pixels height.\n<br>";
echo "<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\"
value=\"20000\">\n";
echo "<INPUT TYPE=\"file\" NAME=\"users_file\"><BR>\n";
echo "<INPUT TYPE=\"checkbox\" NAME=\"inverse\">Invert colors<br>\n";
echo "<INPUT TYPE=\"submit\" VALUE=\"Convert\">\n";
echo "</FORM>\n";
echo "</font></td></tr></table></body></html>\n";
}
?>
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.