Landon Call Landon Call - 3 years ago 137
PHP Question

How to check size of a file in PHP

I am trying to check the size of my file using echo $_FILES['photo']['size'] but nothing is being returned.

HTML

<form method="POST" action="sendToDatabase.php">
<fieldset>
<legend>Artwork</legend>
<label>Album Artwork</label>
<input type="file" name="art" />
<p>
File must be saved as a .jpg file.<br />Please crop to 150px wide X 200px tall before uploading.
</p>
</fieldset>

<input type="submit" name="submit" value="Submit Album" class="submitBtn" />
</form>


PHP

<?php echo $_FILES['art']['size']; ?>

Answer Source

you need to add enctype="multipart/form-data" into form tag

enctype="multipart/form-data"


<form method="POST" action="sendToDatabase.php" enctype="multipart/form-data" >
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download