Sonoo Sonoo - 28 days ago 7
PHP Question

echoing file info after input it with form on php

I want to get user selected file size or type...

what is the php codes for it?

<?php
if(isset($_POST['add_file'])){
(what codes?)
}
?>
<form method="post" enctype="multipart/form-data">
<input name="file" type="file">
<input type="submit" name="add_file" value="Choose your file!">
</form>

Answer Source

I found my answer in this form:

<form method="post" enctype="multipart/form-data">
    <input name="file" type="file">
    <input type="submit" name="add_file" value="Choose your file!">
</form>
<br/>
<div>
<?php
if(isset($_POST['add_file'])){
    echo 'Size(bit):'.$_FILES["file"]["size"].'<br/>Type:'.$_FILES["file"]["type"];
}
?>
</div>

I can't access to file directory of user... cause this is a form of attacking.