Not sure what you're tring to achieve, but that only checks the file's 
name. You might want to use file (man 1 file) to verify that it actually 
is a JPEG, since people can put malicious data into a file named xxx.jpg 
and perhaps fool IE into doing bad things.

miguel

On Wed, 17 Apr 2002, jas wrote:

> Oops... Hope this helps others, here is what I did:
> // This is your form...
> <form name="img1" method="post" action="done.php" target="box"
> enctype="multipart/form-data">
>         <input type="file" name="img1" size="25">
>         <br><br>
>         <input type="submit" name="Submit" value="save">
>         &nbsp;&nbsp;
>         <input type="reset" name="reset" value="reset">
>       </form>
> // this is the script to upload the file
> // Note:  if you want to only upload certain file types... change the
> eregi('.jpg$ sting to whatever your file extension should be
> // Also the directory in question needs permissions set to 755 for it to
> work.
> <?php
> if ($img1_name != "" && eregi('.jpg$', $img1_name)) {
> @copy("$img1", "/path/to/directory/$img1_name") or die ("Could not upload
> file, please try again after making sure the file is less than 2mb in size
> and the file name correct");
>  } else {
>    die("No file selected for upload, or the file was not the correct type.
> Please only upload .jpg files.");
>     }
> ?>
> 
> "Michael Andersson" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Maybe you want to share with the rest of us, or at least me how you did
> it?
> > :)
> >
> > /Micke
> > "Jas" <[EMAIL PROTECTED]> skrev i meddelandet
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Nevermind... =)
> > > "Jas" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > I am wondering if any one has a good idea on how to do checking based
> on
> > a
> > > > files extension, what I am trying to accomplish is to be able to
> upload
> > > > files to a webserver however I only want to have .jpg files uploaded.
> > If
> > > > anyone has a good way to do this please share.
> > > > Thanks in advance,
> > > > Jas
> > > >
> > > >
> > >
> > >
> >
> >
> 
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to