Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-12
4
Medium Priority
?
201 Views
Last Modified: 2010-04-21
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?

0
Comment
Question by:mgtm3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 21769832
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
 

Author Comment

by:mgtm3
ID: 21769865
how can i tell it to provide this?
0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 2000 total points
ID: 21769956
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
 

Author Closing Comment

by:mgtm3
ID: 31466568
thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question