What potential issue did the user in the forum thread face when trying to limit the file size of an uploaded file using filesize()?
The potential issue the user faced when trying to limit the file size of an uploaded file using `filesize()` is that `filesize()` returns the size of the file on disk, not the size of the file being uploaded. To limit the size of the uploaded file, the user should use `$_FILES['file']['size']` instead.
if ($_FILES['file']['size'] > 1000000) {
echo "File size must be less than 1MB.";
exit;
}
Keywords
Related Questions
- How can SQL injection vulnerabilities be prevented in PHP code, especially when executing SQL queries like updates?
- How can PHP functions be utilized to filter out non-numeric values from an array before finding the maximum value?
- How feasible is it to create a database of valid words (like a "Duden") to compare strings against for filtering purposes in PHP?