Entry
How can I get information (name, size, type) about an uploaded file?
Jan 16th, 2000 15:49
Nathan Wallace, Gan, Richard Lynch
PHP automatically creates variable names based on the name you use in
the upload file form. Here are some examples:
FILE FILE NAME FILE SIZE FILE TYPE
$file $file_name $file_size $file_type
$filename $filename_name $filename_size $filename_type
$userfile $userfile_name $userfile_size $userfile_type
$foo $foo_name $foo_size $foo_type
You can also use <?php phpinfo();?> on the upload page to see what is
being set.
Here is an simple example of an upload file form:
<HTML><BODY>
<?php
if (isset($file)){
echo "Successfully uploaded ", $file_name, "<BR>\n";
}
?>
<FORM ACTION=samepage.php3 METHOD=POST>
<INPUT TYPE=FILE NAME=file><BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY></HTML>