note 129302 added to ini.core

From: Date: Sun, 03 Mar 2024 21:17:43 +0000
Subject: note 129302 added to ini.core
Groups: php.notes 
Request: Send a blank email to php-notes+get-221229@lists.php.net to get a copy of this message
As an addendum or continuation to my previous note, I made a mistake: I had said that "$_FILES['arquivo']['size'] is equal to 0", however, $_FILES['arquivo']['size'] is equal to NULL due to the 'post_max_size' and 'upload_max filesize' directives being set. The code is at the end. For example: $uploadfile = $uploaddir . basename($_FILES['arquivo']['name']); generate warnings Warning: Undefined array key "file" in C:\Apache24\htdocs\email\upload.php on line 7 Warning: Trying to access array offset on null in C:\Apache24\htdocs\email\upload.php on line 7 both with $_FILES['arquivo']['name'] and $_FILES['arquivo']['tmp_name']. And $file = $_FILES['arquivo']; generates the warning Warning: Undefined array key "file" in C:\Apache24\htdocs\email\upload.php on line 30. And the var_dump var_dump($arquivo['size']); var_dump($arquivo['name']); var_dump($bytesup); var_dump($bytespost); generate warnings Warning: Trying to access array offset on null in C:\Apache24\htdocs\email\upload.php on line 55 NULL Warning: Trying to access array offset on null in C:\Apache24\htdocs\email\upload.php on line 56 NULL int(2097152) int(2097152) Conversion of the strings 'post_max_size (2M)' and 'upload_max_file_size (2M)' is being done. The issue is that because the values are set in php.ini (it cannot be different), they come as NULL (it is correct). In the warning sent when clicking the Submit button (<input type="submit" name="enviar_arquivo" value="Enviar">) after selecting a file, we have Warning: POST Content-Length of 2638181 bytes exceeds the limit of 2097152 bytes in Unknown on line 0 which tells us that the Content-Length (size of the selected file) exceeds the limit on 'upload_max_filesize'. We know that it is in 'upload_max_filesize' because 'post_max_size' was set to '2.1M'. A solution to send a message to the user informing that the file exceeds the allowed size, in addition to other messages, (in case it is sent by POST in HTML) is the following: In the next note... ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.131 (proxied: 2804:14d:7682:8097:8c1c:9004:2855:e419) ---- Manual Page -- https://php.net/manual/en/ini.core.php Edit -- https://main.php.net/note/edit/129302 Del: integrated -- https://main.php.net/note/delete/129302/integrated Del: useless -- https://main.php.net/note/delete/129302/useless Del: bad code -- https://main.php.net/note/delete/129302/bad+code Del: spam -- https://main.php.net/note/delete/129302/spam Del: non-english -- https://main.php.net/note/delete/129302/non-english Del: in docs -- https://main.php.net/note/delete/129302/in+docs Del: other reasons-- https://main.php.net/note/delete/129302 Reject -- https://main.php.net/note/reject/129302 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221229) next »