i am trying to make an upload system for in php but i have a problem

i am trying to learn about the $_FILES['type']
there isa problem
i am trying to upload a photo named Untitled3.jpg using this script


<html>
<body>
  <form enctype="multipart/form-data" action="filephp.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="20000" />
    Choose a file to upload: <input name="fffffile" type="file" />
    <input type="submit" value="Upload" />
  </form>
</body>
</html>

and the script

<?php

$type=$_FILES['fffffile']['type'];


echo $type;
?>
when i run this it needs to echo the type of the file jpg
but when i really run it it does not echo i just get blank page

why?

mgtm3Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hieloConnect With a Mentor Commented:
Because the browser is not obligated to provide that information:

 $_FILES['userfile']['type']
    The mime type of the file, if the browser provided this information...
0
 
mgtm3Author Commented:
how can i tell it to provide this?
0
 
hieloConnect With a Mentor Commented:
You (the server programmer) can't "tell" the browser what to do. For example, the browser owner/user may have his/her browser set so that it does NOT include/supply the referrer header. You, the server developer/webmaster do not have control over the browser. The browser will do as the browser owner/user wants, not you. For your purposes, what you can do is obtain the name of the image and check its extension.
0
 
mgtm3Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.