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.

Recommended Answers

All 2 Replies

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 />";

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.