Geen cache-versie.


Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher une fonction PHP

MongoGridFS::storeUpload

(PECL mongo >=0.9.0)

MongoGridFS::storeUploadStores an uploaded file in the database

Description

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

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Parameters

name

The name of the uploaded file(s) to store. This should correspond to the file field's name attribute in the HTML form.

metadata

Other metadata fields to include in the file document.

Note:

These fields may also overwrite those that would be created automatically by the driver, as described in the MongoDB core documentation for the » files collection. Some practical use cases for this behavior would be to specify a custom chunkSize or _id for the file.

Note:

The filename field will be populated with the client's filename (e.g. $_FILES['foo']['name']).

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Return Values

Returns the _id of the saved file document. This will be a generated MongoId unless an _id was explicitly specified in the metadata parameter.

Note:

If multiple files are uploaded using the same field name, this method will not return anything; however, the files themselves will still be processed.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Errors/Exceptions

Throws MongoGridFSException if there is an error reading the uploaded file(s) or inserting into the chunks or files collections.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

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.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Examples

Example #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
$m 
= new MongoClient();
$gridfs $m->selectDB('test')->getGridFS();

$gridfs->storeUpload('pic', array('username' => $_POST['username']));
?>

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

See Also

Zoek een PHP-functie

Vertaling niet beschikbaar

De PHP-handleiding is nog niet in het Nederlands vertaald, dus het scherm is in het Engels. Als u wilt, kunt u het ook in het Frans of in het Duits raadplegen.

Als je de moed voelt, kun je je vertaling aanbieden ;-)

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 30/01/2003 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/php-rf-mongogridfs.storeupload.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : http://php.net

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut