Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
can't get OR function to work with NOT
Old 12-26-2008, 07:40 PM can't get OR function to work with NOT
Skilled Talker

Posts: 69
Trades: 0
I am testing the file format of an image to upload. For some reason it is stil passing as file not in the list

Code:
$testimgformat=explode('.',$img1_name);
$imgformat=$testimgformat[sizeof($testimgformat)-1];
if (!($imgformat==jpg) || !($imgformat==gif) || !($imgformat==JPG) || !($imgformat==GIF) || !($imgformat==bmp) || !($imgformat==BMP))
{$er=$er+1;
echo "<center><font color='red'>Your file must be of jpg, bmp or gif format.</font><br></center>";}
Any help appreciated.
__________________
Matt
webmaster of
Please login or register to view this content. Registration is FREE
- Online wedding planning
weddingm is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-26-2008, 08:03 PM Re: can't get OR function to work with NOT
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the extensions should be in quotes for a start
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-26-2008, 08:43 PM Re: can't get OR function to work with NOT
Skilled Talker

Posts: 69
Trades: 0
got it!

Quote:
$testimgformat=explode('.',$img1_name);
$imgformat=strtolower($testimgformat[sizeof($testimgformat)-1]);
if (($imgformat != "jpg") && ($imgformat != "jpeg") && ($imgformat != "bmp") && ($imgformat != "gif") && ($imgformat != "png"))
{$er=$er+1;
echo "<center><font color='red'>Your file must be of jpg, bmp, png or gif format.</font><br></center>";}
__________________
Matt
webmaster of
Please login or register to view this content. Registration is FREE
- Online wedding planning
weddingm is offline
Reply With Quote
View Public Profile
 
Old 12-27-2008, 04:06 AM Re: can't get OR function to work with NOT
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Php already has the function Pathinfo http://uk3.php.net/pathinfo. This will return an array which includes the file extension.

Also as your files are image files only then you should be using getimagesize http://uk.php.net/manual/en/function.getimagesize.php . This will return an array including mimetype such as [mime] => image/jpeg. If file is not an image then FALSE is returned.
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can't get OR function to work with NOT
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.57588 seconds with 12 queries