Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have a working script, someone gave me, I am trying to modify. I have the following segment:
Code:
$upload_file = $_FILES['upload_file']['name']; 
$size = $_FILES['upload_file']['size']; 
$temp = $_FILES['upload_file']['tmp_name'];
This segment is handling a 'post' in which 'upload_file' is the passed file name. What I want to do is extract the file extension but I cannot find anything in the documentation on '$_FILES'. Trying the obvious:
Code:
$type = $_FILES['upload_file']['type'];
or:
Code:
$type = $_FILES['upload_file']['ext'];
does not work.

Can someone point me in the right direction? Thanks.
 
Thanks for the reply but you cheated. :)

I should have thought of that but I still really want to know what other information $_FILES contains and why I cannot find it in the docs.
 
[smile]
............................................................
the common function to know the file type is $_FILES['userfile']['type'], an example of a return is 'image/gif', I am sure that you already had seen this, but I believe this is the only way....

more...
$_FILES['userfile']['name']
The original name of the file on the client machine.

$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An example would be "image/gif".

$_FILES['userfile']['size']
The size, in bytes, of the uploaded file.

$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was stored on the server.

$_FILES['userfile']['error']
The error code associated with this file upload. ['error'] was added in PHP 4.2.0


more on...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top