|
MongoGridFS::storeUploadStores an uploaded file in the database Description
public mixed MongoGridFS::storeUpload
( string
$name
[, array $metadata
] )Parameters
Return ValuesReturns the _id of the saved file document. This will be a generated MongoId unless an _id was explicitly specified in the
Errors/ExceptionsThrows MongoGridFSException if there is an error reading the uploaded file(s) or inserting into the chunks or files collections. Changelog
ExamplesExample #1 MongoGridFS::storeUpload HTML form example Suppose you have the following HTML form: <form method="POST" enctype="multipart/form-data"> <label for="username">Username:</label> <input type="text" name="username" id="username" /> <label for="pic">Please upload a profile picture:</label> <input type="file" name="pic" id="pic" /> <input type="submit" /> </form> If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:
<?php See Also
|