Re: Files types



Bill wrote:
Janwillem Borleffs wrote:
Bill schreef:
Can anyone point me in the right direction. I am trying to upload jpg
images and using the following piece of code
$myerror = "no";
$msg = "ok";
$img_types = array('image/jpeg','image/jpg','image/pjpeg');
if (!in_array($_FILES['imagefile']['type'],$img_types))
{
$msg = 'Problem: file is not jpg';
$myerror = "yes";
}
echo $msg;
When I try to download a jpg I still get the problem msg.
Is there something that I am doing wrong that I cant see or is there
another way to do this.
Thanks in advance


What is the output when you print $_FILES['imagefile']['type']?


JW

i tried
$newname = $_FILES['imagefile']['type'];
echo $newname;
and got nothing.
Is there something I have to do to make this work
Thanks

Try with

var_dump($_FILES);

and see what is set in the variable when an upload has been done and
it's easier to see things if you look at the webpage source code than
looking at the output in the browser (browsers don't care about new lines).

--

//Aho
.



Relevant Pages

  • Re: Files types
    ... echo $msg; ... When I try to download a jpg I still get the problem msg. ... echo $newname; ...
    (alt.php)
  • Re: Files types
    ... echo $msg; ... When I try to download a jpg I still get the problem msg. ...
    (alt.php)
  • Re: Problem in opening websites
    ... msg is "there was no XML in the response". ... the browser gets timed out (the msg is "The connection ... to the server was reset while the page was loading."). ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: [slrn] macro to search message-id
    ... The script behaves like ... article's detected msg ids. ... If the article is on my spool (I use ... For the record I use elinks as my browser and changed the default google ...
    (news.software.readers)
  • Re: [PHP] if(), else() problem!
    ... Rahul S. Johari wrote: ... echo ³not found²; ... $msg = 'database contains no records!'; ... The loop reads each row in the database, ...
    (php.general)