0

hi,
i am new to php. i had a query about how to get the file name and file size of the uploaded file. so that i can display it in a table.
thank u.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by metalix
0

Might need a bit more info, but does this help?

echo "Uploaded file name: " . $_FILES["file"]["name"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
0

Along with the file, information about the file is sent with the form. This information is stored in the PHP built-in array called $_FILES. An array of information is available for each file that was uploaded. As with any other form, you can obtain the information from the array by using the name of the field. ex: you can get information about the uploaded file from the following array:
User inputs:

<input type=”file” name=”user_file”>

resulting array:

$_FILES[user_file][name] = test.txt
$_FILES[user_file][type] = text/plain
$_FILES[user_file][tmp_name] = D:\WINNT\php92C.tmp
$_FILES[user_file][size] = 435

just remember to set a max file size or the default is 8mb

Hopefully this helped :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.