<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Stores a file in the database</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongogridfs.get.html">MongoGridFS::get</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongogridfs.remove.html">MongoGridFS::remove</a></div> <div class="up"><a href="class.mongogridfs.html">MongoGridFS</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongogridfs.put" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoGridFS::put</h1> <p class="verinfo">(PECL mongo >=1.0.8)</p><p class="refpurpose"><span class="refname">MongoGridFS::put</span> — <span class="dc-title">Stores a file in the database</span></p> </div> <div class="refsect1 description" id="refsect1-mongogridfs.put-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>MongoGridFS::put</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$metadata</code><span class="initializer"> = array()</span></span> ] )</div> </div> <div class="refsect1 parameters" id="refsect1-mongogridfs.put-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"> <em><code class="parameter">filename</code></em> </span> <dd> <p class="para"> Name of the file to store. </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">metadata</code></em> </span> <dd> <p class="para"> Other metadata fields to include in the file document. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">These fields may also overwrite those that would be created automatically by the driver, as described in the MongoDB core documentation for the <a href="http://docs.mongodb.org/manual/core/gridfs/#the-files-collection" class="link external">» files collection</a>. Some practical use cases for this behavior would be to specify a custom <em>chunkSize</em> or <em>_id</em> for the file.</p></p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-mongogridfs.put-returnvalues"> <h3 class="title">Return Values</h3> <p class="para">Returns the <em>_id</em> of the saved file document. This will be a generated <a href="class.mongoid.html" class="classname">MongoId</a> unless an <em>_id</em> was explicitly specified in the <em><code class="parameter">extra</code></em> parameter.</p> </div> <div class="refsect1 seealso" id="refsect1-mongogridfs.put-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"> <span class="function"><a href="mongogridfs.storebytes.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeBytes()</a> - Stores a string of bytes in the database</span></li> <li class="member"> <span class="function"><a href="mongogridfs.storefile.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeFile()</a> - Stores a file in the database</span></li> <li class="member"> <span class="function"><a href="mongogridfs.storeupload.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeUpload()</a> - Stores an uploaded file in the database</span></li> <li class="member">MongoDB core docs on <a href="http://docs.mongodb.org/manual/core/gridfs/" class="link external">» GridFS</a></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongogridfs.get.html">MongoGridFS::get</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongogridfs.remove.html">MongoGridFS::remove</a></div> <div class="up"><a href="class.mongogridfs.html">MongoGridFS</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>