note 120312 added to index

From: Date: Sun, 11 Dec 2016 19:13:51 +0000
Subject: note 120312 added to index
Groups: php.notes 
Request: Send a blank email to php-notes+get-208563@lists.php.net to get a copy of this message
Multiple file upload: <html lang="en"> <head> <meta charset="UTF-8" /> <title>Multiple File Ppload with PHP</title> </head> <body> <form action="" method="post" enctype="multipart/form-data"> <input type="file" id="file" name="files[]" multiple="multiple" accept="image/*" /> <input type="submit" value="Upload!" /> </form> </body> </html> <?php $valid_formats = array("jpg", "png", "gif", "zip", "bmp"); $max_file_size = 1024*100; //100 kb $path = "uploads/"; // Upload directory $count = 0; if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){ // Loop $_FILES to exeicute all files foreach ($_FILES['files']['name'] as $f => $name) { if ($_FILES['files']['error'][$f] == 4) { continue; // Skip file if any error found } if ($_FILES['files']['error'][$f] == 0) { if ($_FILES['files']['size'][$f] > $max_file_size) { $message[] = "$name is too large!."; continue; // Skip large files } elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){ $message[] = "$name is not a valid format"; continue; // Skip invalid file formats } else{ // No error found! Move uploaded files if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name)) $count++; // Number of successfully uploaded file } } } } ?> http://www.travelforu.info ---- Server IP: 203.211.135.122 Probable Submitter: 115.124.45.210 ---- Manual Page -- http://php.net/manual/en/index.php Edit -- https://master.php.net/note/edit/120312 Del: integrated -- https://master.php.net/note/delete/120312/integrated Del: useless -- https://master.php.net/note/delete/120312/useless Del: bad code -- https://master.php.net/note/delete/120312/bad+code Del: spam -- https://master.php.net/note/delete/120312/spam Del: non-english -- https://master.php.net/note/delete/120312/non-english Del: in docs -- https://master.php.net/note/delete/120312/in+docs Del: other reasons-- https://master.php.net/note/delete/120312 Reject -- https://master.php.net/note/reject/120312 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208563) next »