473,837 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Upload and conversion not working

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.p hp"); ?>
<table bgcellpadding=0 cellspacing=0 border=0 width="100%">
<tr>
<td align="left" valign="top"><? include("sommai re.php"); ?></td>
<td><img src="img/20pix.gif" border=0></td>
<td width="100%" valign="top" align="left">
<? echo "<br><br><i mg 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.p hp3?disp=bmp2wb mp\"><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.p hp3?disp=bmp2wb mp\"><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.p hp3?disp=bmp2wb mp\"><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.p hp3?disp=bmp2wb mp\"><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.p hp3?disp=bmp2wb mp\"><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_f ile_name;
if ((strstr($users _file_name,".bm p")!=".bmp")&&( strstr($users_f ile_name,".BMP" )!=".BMP"))
{
traite_err(1,0) ;
}

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

$outfname=$fnam e.".wbmp";
$f_size=filesiz e($users_file);
if ($f_size>2000)
{
traite_err(2,0) ;
}
$aabenFil = fopen($users_fi le, "r");
$filindhold = fread($aabenFil , filesize($users _file));

$B=$filindhold[0];
$M=$filindhold[1];
$bfsize=ord($fi lindhold[2])+ 256 * ord($filindhold[3]);
$bfOffBits=ord( $filindhold[10])+ 256 * ord($filindhold[11]);
$largeur=ord($f ilindhold[18]) + 256 * ord($filindhold[19]);
$hauteur=ord($f ilindhold[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,$l argeur);
}

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

$j=0;

$nbcharlarg=$la rgeur/8;

$numline=0;

for($i=0;$i<fil esize($users_fi le)-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=".$out fname );
Header( "Content-Disposition: filename=".$out fname );
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.p hp"); ?>
<table bgcellpadding=0 cellspacing=0 border=0 width="100%">
<tr>
<td align="left" valign="top"><? include("sommai re.php"); ?></td>
<td><img src="img/20pix.gif" border=0></td>
<td width="100%" valign="top" align="left"><?
echo "<br><br><i mg border=\"0\" src=\"img/bmp2wbmp.gif\" width=\"346\"
height=\"22\" border=\"0\">\n ";
echo "<FORM ACTION=\"index2 .php3?disp=bmp2 wbmp\"
ENCTYPE=\"multi part/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_fi le\"><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
0 1720

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

Similar topics

3
6712
by: Guoqi Zheng | last post by:
Dear Sir, I am trying to use do a upload function on my site. I got a upload class from Internet. However, sometimes, it works, sometimes, it give me the following error. Microsoft VBScript runtime error '800a0005' Invalid procedure call or argument /viplogin/include/UploadClass.asp, line 136
4
2206
by: M P | last post by:
Can you help me find an asp code that will upload a file from my PC to web server? Mark
1
3029
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The welcome page has a browse button (for locating your local file), a textfield where the path is displayed, and a upload button. When clicking upload a VB ASP script is run, and the outcome is displayed on a new page. 1. On my local machine I got the...
13
4332
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
18
4366
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a "Cannot connect to remote server" error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
8
3493
by: mpar612 | last post by:
Hello, I am a newbie to PHP, MySQL. I am trying to create a basic file upload form. I want to get that working and then I want to integrate that into a form that will rename the file and save it to a directory and store the path to the file in the db, in addition to storing other text from other fields in the form. Then I will get that path using PHP to display the image file in a browser. First things first, I'm having difficulty...
12
2913
by: SAL | last post by:
Hello, Is it possible to read a CSV from the Client, and bind my Datagrid to the data in the CSV file without uploading the file to the Server first? I have tried and in Debug mode on my workstation it works fine, but when I publish the page on our DEV server it doesn't fine the CSV file from the client. Has anyone done this before? If so, how do I do it? I'm new to ASP.net so
4
6923
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
6
3841
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the network should be able to connect to the database and run queries on the database or upload new music that does not yet exist on the database. The uploaded file's name should be in the following format: ARTIST - TITLE.mp3. I have the code to upload images,...
0
9846
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10580
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9413
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7817
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5674
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.