PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

MongoGridFS::storeUpload

(PECL mongo >=0.9.0)

MongoGridFS::storeUploadSaves an uploaded file to the database

Description

public mixed MongoGridFS::storeUpload ( string $name [, array $metadata ] )

Stores files directly from a POST to the database. For example, suppose you had the following HTML form:

<form method="POST" enctype="multipart/form-data">
     Please upload a profile picture: <input type="file" name="pic"/>
     <input type="submit"/>
</form>

If you wanted to store this upload in MongoDB, you could do:

<?php

$grid
->storeUpload("pic", array("username" => "joe"));

?>

Note that the "name" field in HTML matches the name parameter.

Parameters

name

The name field of the uploaded file.

metadata

An array of extra fields for the uploaded file.

Return Values

Returns the _id of the uploaded file.

Changelog

Version Description
1.2.5 Changed second parameter to an array of metadata. Pre-1.2.5, the second parameter was an optional string overriding the filename.

PHP Manual