note 104241 added to features.file-upload.multiple

From: Date: Fri, 03 Jun 2011 06:04:41 +0000
Subject: note 104241 added to features.file-upload.multiple
Groups: php.notes 
Request: Send a blank email to php-notes+get-180212@lists.php.net to get a copy of this message
<?php $uploaded = 0; $message = array(); foreach ($_FILES['image']['name'] as $i => $name) { if ($_FILES['image']['error'][$i] == 4) { continue; } if ($_FILES['image']['error'][$i] == 0) { if ($_FILES['image']['size'][$i] > 99439443) { $message[] = "$name exceeded file limit."; continue; } /* * Check File Extension * Move File */ $uploaded++; } } echo $uploaded . ' files uploaded.'; foreach ($message as $error) { echo $error; } ?> How to handle multiple $_FILES is quite easy i would use continue and build a further array for error messages to be displayed for output to the user, this is very good as say if you accept 4 of the 10 files the user uploads u can show 6 messages stating there file extensions are not allowed and then say a few was uploaded. Enjoy! ---- Server IP: 69.147.83.197 Probable Submitter: 92.24.144.214 ---- Manual Page -- http://www.php.net/manual/en/features.file-upload.multiple.php Edit -- https://master.php.net/note/edit/104241 Del: integrated -- https://master.php.net/note/delete/104241/integrated Del: useless -- https://master.php.net/note/delete/104241/useless Del: bad code -- https://master.php.net/note/delete/104241/bad+code Del: spam -- https://master.php.net/note/delete/104241/spam Del: non-english -- https://master.php.net/note/delete/104241/non-english Del: in docs -- https://master.php.net/note/delete/104241/in+docs Del: other reasons-- https://master.php.net/note/delete/104241 Reject -- https://master.php.net/note/reject/104241 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180212) next »