note 91479 added to features.file-upload.post-method
| From: | daevid at daevid dot com | Date: | Thu, 11 Jun 2009 21:35:44 +0000 |
| Subject: | note 91479 added to features.file-upload.post-method | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156787@lists.php.net to get a copy of this message | ||
I think the way an array of attachments works is kind of cumbersome. Usually the PHP guys are right
on the money, but this is just counter-intuitive. It should have been more like:
Array
(
[0] => Array
(
[name] => facepalm.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpn3FmFr
[error] => 0
[size] => 15476
)
[1] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] =>
)
)
and not this
Array
(
[name] => Array
(
[0] => facepalm.jpg
[1] =>
)
[type] => Array
(
[0] => image/jpeg
[1] =>
)
[tmp_name] => Array
(
[0] => /tmp/phpn3FmFr
[1] =>
)
[error] => Array
(
[0] => 0
[1] => 4
)
[size] => Array
(
[0] => 15476
[1] => 0
)
)
Anyways, here is a fuller example than the sparce one in the documentation above:
<?php
foreach ($_FILES["attachment"]["error"] as $key => $error)
{
$tmp_name = $_FILES["attachment"]["tmp_name"][$key];
if (!$tmp_name) continue;
$name = basename($_FILES["attachment"]["name"][$key]);
if ($error == UPLOAD_ERR_OK)
{
if ( move_uploaded_file($tmp_name, "/tmp/".$name) )
$uploaded_array[] .= "Uploaded file '".$name."'.<br/>\n";
else
$errormsg .= "Could not move uploaded file '".$tmp_name."' to
'".$name."'<br/>\n";
}
else $errormsg .= "Upload error. [".$error."] on file
'".$name."'<br/>\n";
}
?>
----
Server IP: 209.41.74.194
Probable Submitter: 206.169.197.253
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.post-method.php
Edit -- https://master.php.net/note/edit/91479
Del: integrated -- https://master.php.net/note/delete/91479/integrated
Del: useless -- https://master.php.net/note/delete/91479/useless
Del: bad code -- https://master.php.net/note/delete/91479/bad+code
Del: spam -- https://master.php.net/note/delete/91479/spam
Del: non-english -- https://master.php.net/note/delete/91479/non-english
Del: in docs -- https://master.php.net/note/delete/91479/in+docs
Del: other reasons-- https://master.php.net/note/delete/91479
Reject -- https://master.php.net/note/reject/91479
Search -- https://master.php.net/manage/user-notes.php