note 110902 deleted from features.file-upload by aharvey
| From: | aharvey@php.net | Date: | Sat, 22 Dec 2012 05:14:26 +0000 |
| Subject: | note 110902 deleted from features.file-upload by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192640@lists.php.net to get a copy of this message | ||
Note Submitter: nabikaz at gmail dot com
----
create $_FILES array from list of files in a directory
<?php
$_FILES = array();
$i = 0;
$tempDir = "/upload/";
foreach (glob($tempDir . "*") as $filename) {
if (filetype($filename) == 'dir') continue;
if ($filename == '.' || $filename == '..') continue;
$_FILES['file']['name'] [$i] = pathinfo($filename, PATHINFO_BASENAME);
$_FILES['file']['type'] [$i] = mime_content_type($filename);
$_FILES['file']['tmp_name'] [$i] = $filename;
$_FILES['file']['error'] [$i] = UPLOAD_ERR_OK;
$_FILES['file']['size'] [$i] = filesize($filename);
$i++;
}
?>
* You sure installed fileinfo pecl extension
* Forgot that about this created array, is_uploaded_file function return false and you can not use
move_uploaded_file function for save as file, so you just can use copy function for save tmp_name