473,405 Members | 2,282 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,405 software developers and data experts.

Problems with BMP files and security questions

First questions was already posted over on a.php, but no one responded, so
I'm gonna post it again here:

So I have a block of code that is used when a user uploades a picture file.
Initially the script detects what kind of picture file the user uploaded and
then acts accordingly. The following is the code for a jpeg:

if($t == 'image/jpeg'){

$src_img = ImagecreateFromJpeg($uploadfile);
$size = getimagesize("../album/users/$uname/$album/$pic_name");
$width = $size[0];
$height = $size[1];

$width = round(($width/4));
$height = round(($height/4));
$dst_img = ImageCreateTrueColor($width,$height);

ImageCopyResized($dst_img, $src_img, 0,0,0,0, $width, $height, $size[0],
$size[1]);

ImageJpeg($dst_img, "users/$uname/$album/small/$pic_name", 60);
Basically, makes a picture is the appropriate folder, then resizes makes a
copy 1/4th the size before in another folder. Now, I can pretty much reuse
this code with gifs and pngs, by just changing the relevant functions, but
here's my question: with bmp files, it wont seem to work at all. It gives an
error message that basically says that the bmp file the user uploades isnt a
valid bmp file. Any idea how to get that to work?
The second question I have is in regards to security and PHP. I'm basically
making my first web application that other people might actually use, so I
have to make sure it's secure. So far, what I plan on doing is making sure
that data from users is not left blank, doesn't exceed the expected length,
and whenever possible is completely alphanumeric. With the file uploads, I'm
checking for file type as well. Is there anything else that I should keep in
mind? Also, I'm not really that good at regular expressions yet, so if
someone could tell me if some of the reg. exps. I'm using are adequate would
be good.
To check for a valid email:
^[a-zA-z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$
and
to check that data is alphanumeric: [^0-9a-zA-z]

Thanks a lot in advance.
--
<=============>
--Lee
http://www.inaneasylum.org

Goodbye, adios, bis bald, see ya later, weidersehen, and everything in
between
Jul 17 '05 #1
6 1725
*** Lee Marsh escribió/wrote (Tue, 25 Jan 2005 04:05:49 GMT):
here's my question: with bmp files, it wont seem to work at all. It gives an
error message that basically says that the bmp file the user uploades isnt a
valid bmp file. Any idea how to get that to work?


Just find out what MIME type is set when you upload a BMP file.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #2
See, thats the easy part though. There's different functions for handeling
bmp's as there is for handeling jpeg's, but it doesn't seem like i can get
any of the ones that might work for bmps to work right and i have no idea
why.

--
<=============>
--Lee
http://www.inaneasylum.org

Goodbye, adios, bis bald, see ya later, weidersehen, and everything in
between
"Alvaro G. Vicario" <kA*****************@terra.es> wrote in message
news:1b*****************************@40tude.net...
*** Lee Marsh escribió/wrote (Tue, 25 Jan 2005 04:05:49 GMT):
here's my question: with bmp files, it wont seem to work at all. It gives
an
error message that basically says that the bmp file the user uploades
isnt a
valid bmp file. Any idea how to get that to work?


Just find out what MIME type is set when you upload a BMP file.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la
intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--

Jul 17 '05 #3
Lee Marsh wrote:
See, thats the easy part though. There's different functions for handeling
bmp's as there is for handeling jpeg's, but it doesn't seem like i can get
any of the ones that might work for bmps to work right and i have no idea
why.


The problem you're encountering probably is simply a mis-understanding
of the functions. The ImageCreateFromWBMP is not for bitmap images, at
least not the way you are thinking. If you look at the first user
comment, you will see:

<quote>
WBMP images are Wireless Bitmaps, not Windows Bitmaps. WBMP is used for
bandwidth constrained, black and white, limited devices such as PDAs and
Cell Phones.
</quote>

So, normal bitmaps, like you create in MS Paint, are not valid for these
functions. To be honest, I'm not sure if there are any functions for
these images.
Jul 17 '05 #4
*** Lee Marsh escribió/wrote (Wed, 26 Jan 2005 03:04:33 GMT):
See, thats the easy part though. There's different functions for handeling
bmp's as there is for handeling jpeg's, but it doesn't seem like i can get
any of the ones that might work for bmps to work right and i have no idea
why.


My excuses, I didn't actually read your complete post, I was scared by the
code <:-) I just read 'upload' and 'detect' and...

The manual says about image functions:

"It can also be used to create and manipulate image files in a variety of
different image formats, including gif, png, jpg, wbmp, and xpm."

Some of the functions work with BMP files (e.g. getimagesize) but most of
them don't. If it's a Unix server you probably have ImageMagick installed.
This packege includes very useful commands to handle most graphic formats
and can be invoked via exec().
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #5
Gotcha. So I guess my site won't be able to support BMP files. Just out of
curiosity, any idea why PHP doesn't support BMP files in that sense?

PS
I guess I'll have so post my second question again in another group since
it's buried now...

--
<=============>
--Lee

Goodbye, adios, bis bald, see ya later, weidersehen, and everything in
between
"Alvaro G. Vicario" <kA*****************@terra.es> wrote in message
news:1j*******************************@40tude.net. ..
*** Lee Marsh escribió/wrote (Wed, 26 Jan 2005 03:04:33 GMT):
See, thats the easy part though. There's different functions for
handeling
bmp's as there is for handeling jpeg's, but it doesn't seem like i can
get
any of the ones that might work for bmps to work right and i have no idea
why.


My excuses, I didn't actually read your complete post, I was scared by the
code <:-) I just read 'upload' and 'detect' and...

The manual says about image functions:

"It can also be used to create and manipulate image files in a variety of
different image formats, including gif, png, jpg, wbmp, and xpm."

Some of the functions work with BMP files (e.g. getimagesize) but most of
them don't. If it's a Unix server you probably have ImageMagick installed.
This packege includes very useful commands to handle most graphic formats
and can be invoked via exec().
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la
intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--

Jul 17 '05 #6
*** Lee Marsh escribió/wrote (Wed, 26 Jan 2005 15:16:28 GMT):
Gotcha. So I guess my site won't be able to support BMP files. Just out of
curiosity, any idea why PHP doesn't support BMP files in that sense?


I guess they have little use in web sites.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #7

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

Similar topics

8
by: Marc Hoeve | last post by:
Hi everybody I'm setting up 2 websites for a friend of mine, en I'm have problems with one of the sites. The situation: I have 2 different domains (both in the .NL domain). Both domains...
1
by: black hawk | last post by:
Hello, i have a big problems, to install oracle 9i v9.2 Server to my "Windows XP" with Service Pack 2 and all security and other updates from Microsoft. The "Universall Installer" (Standard...
0
by: black hawk | last post by:
Hello, i have a big problems, to install oracle 9i v9.2 Server to my "Windows XP" with Service Pack 2 and all security and other updates from Microsoft. The "Universall Installer" (Standard...
1
by: 3f | last post by:
Hello; We have made a web application that people can download from our web site and installed on: Windows XP Windows 2000 Professional Windows 2003 Server Windows 2000 Server
5
by: Girish | last post by:
hey all, im building a asp.net project in vs.net. Is there a way to have the codebehind files sit in a different folder outside the website folder altogether? example: The aspx files are in...
0
by: David Helgason | last post by:
I think those best practices threads are a treat to follow (might even consider archiving some of them in a sort of best-practices faq), so here's one more. In coding an game asset server I want...
18
by: __PPS__ | last post by:
Hello, I'm a university student and I'm preparing for my final today. I'm reading course notes, I found completely strange piece of code. It makes me laugh, I think the teacher needs to prepare...
8
by: per9000 | last post by:
Dear readers, I have some problems with strong keys. What I want to do is basically this. A - create an application (f.x. strongHello.dll) with a strong key. B - import the functions of this...
4
by: =?Utf-8?B?aGFycG8xNA==?= | last post by:
I have installed firefox 3 for my new vista operated machine. I get the following error message: Could not initialise the application's security component. The most probable cause is problems...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.