I always get strpos wrong.
So typically in this case I would do something like:
list($file,$ext) = explode('.',$yourimage);
if ($ext != 'jpg' or $ext != 'jpeg')
{
error...
}
(More properly we should make sure jpg or jpeg are at the very end of the filename
i.e. you probably
don't like myfile.jpegold.gif so you would need:
list($ext,$file) = explode('.',strrev($yourimage));
$ext = strrev($ext);
$file = strrev($file);
if ($ext != 'jpg .....etc.
)
If $yourimage really is a reference to an image e.g. an uploaded image, you might like
to run
getimagesize() on it to see if it really, really is a
jpeg and not just called .jpg or .jpeg see
(http://www.php.net/manual/en/function.getimagesize.php).
George
Jtjohnston wrote:
>
> I suppose I'm doing this right? I want to know if the user entered
> "\.jpeg" or "\.jpg". If he didn't, it should error.
>
> It errors anyways? What do I have to do add slashes in my <input>???
> :o)
>
> // if((!strpos($yourimage, "\.jpg")) || (!strpos($yourimage,
> "\.jpeg"))) \\ <--- tried both!
> if((!strpos($yourimage, ".jpg")) || (!strpos($yourimage, ".jpeg")))
> {
> error_found("error found");
> $errorfound++;
> }
--
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]