Re: [PHP] comparison operators
On Monday 21 May 2001 08:03, Heidi Belal wrote: > I have a form where i let people choose a file to > upload, but i want to limit them to image files only. > So i want to only allow the .gif and .jpg to be > uploaded. What i tried doing was this: > if ($filename_type == "image/gif") >-- upload file > otherwise give an error message! > > but for some reason this doesn't work. It uploads any > kind of file without complaint! So what am i doing > wrong? Is there another operator to compare strings > for instance? Or what is the problem? == is perfectly fine for string comparison. Try doing a echo "'$filename_type'"; and (generally) a phpinfo (); to see what's passed to your script. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. - George Gordon Noel Byron (1788-1824), [Lord Byron] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] comparison operators
Hi All, I have a form where i let people choose a file to upload, but i want to limit them to image files only. So i want to only allow the .gif and .jpg to be uploaded. What i tried doing was this: if ($filename_type == "image/gif") -- upload file otherwise give an error message! but for some reason this doesn't work. It uploads any kind of file without complaint! So what am i doing wrong? Is there another operator to compare strings for instance? Or what is the problem? Thanks! = Heidi Belal ICQ# 32127109 A bus stops at a bus station. A train stops at a train station. On my desk I have a work station... __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] comparison operators
Hi: For compare strings you can use strcmp. $st1 = "hi"; $st2 = "bye"; if (strcmp($st1, $st2)) { echo "are different"; } else { echo "are equal"; } The strcmp return 0 when the strings are equal. If the strings are diferent, return the pos of the char where begin the diference. I think you can use this without problems. I can see that you upload files. My problem it's that i can do it. Y use the form like this. Send this file: My problem is that i don't know how to do the php program that i upload the file. Can you help me?. Thanks. Best Regards Diego Heidi Belal escribió: > Hi All! > i'm creating this form for people to upload pictures, > so i want to be able to compare the type of the file, > so that if it's not a .gif or a .jpg i give them an > error message! > What i am using is: > > If ($userfile_type == "image/gif") >- here it uploads the file > otherwise it sends out an error message! > > but the problem i'm having is that even when i try > uploading a .txt it accepts it and uploads it without > giving the error message. > Is there another way to compare strings? or is == > operater correct? or what am i doing wrong? > thanks! > > = > Heidi Belal > ICQ# 32127109 > > A bus stops at a bus station. > A train stops at a train station. On my desk > I have a work station... > > __ > Do You Yahoo!? > Yahoo! Auctions - buy the things you want at great prices > http://auctions.yahoo.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] comparison operators
Hi All! i'm creating this form for people to upload pictures, so i want to be able to compare the type of the file, so that if it's not a .gif or a .jpg i give them an error message! What i am using is: If ($userfile_type == "image/gif") - here it uploads the file otherwise it sends out an error message! but the problem i'm having is that even when i try uploading a .txt it accepts it and uploads it without giving the error message. Is there another way to compare strings? or is == operater correct? or what am i doing wrong? thanks! = Heidi Belal ICQ# 32127109 A bus stops at a bus station. A train stops at a train station. On my desk I have a work station... __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] comparison operators
Hi All! i'm creating this form for people to upload pictures, so i want to be able to compare the type of the file, so that if it's not a .gif or a .jpg i give them an error message! What i am using is: If ($userfile_type == "image/gif") - here it uploads the file otherwise it sends out an error message! but the problem i'm having is that even when i try uploading a .txt it accepts it and uploads it without giving the error message. Is there another way to compare strings? or is == operater correct? or what am i doing wrong? thanks! = Heidi Belal ICQ# 32127109 A bus stops at a bus station. A train stops at a train station. On my desk I have a work station... __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] comparison operators
Hi All! i'm creating this form for people to upload pictures, so i want to be able to compare the type of the file, so that if it's not a .gif or a .jpg i give them an error message! What i am using is: If ($userfile_type == "image/gif") - here it uploads the file otherwise it sends out an error message! but the problem i'm having is that even when i try uploading a .txt it accepts it and uploads it without giving the error message. Is there another way to compare strings? or is == operater correct? or what am i doing wrong? thanks! = Heidi Belal ICQ# 32127109 A bus stops at a bus station. A train stops at a train station. On my desk I have a work station... __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]