0

in this example "path" is path to (uploaded)temporary file in server? or file path in client's device? i'm reading files metadata from $_FILES but don't know where to read the file to store in db. please help. (sorry for my english)

<?php
    // connect to the ‘myGrid’ GridFS
    $m = new Mongo();
    $db = $m->myDB;
    $myGrid = $db->getGridFS('myGrid');
    $some_file='path of your video or audio file';
    // some extra data you may want to store with your file
    $data_array = array(
        'mime' => mime_content_type($some_file),
        'timestamp' => time(),
    );

    // store a file into the GridFS
    $myGrid->storeFile($some_file, $data_array);
?>
Mher Didaryan
  • 95
  • 2
  • 13
  • `$_FILES['foo']['tmp_name']` is the location where PHP has TEMPORARILY stored the file on the server. But be warned: storing files in a DB is generally a bad idea, and has very few usage cases that justify it. – Marc B Apr 07 '14 at 17:21
  • for a file(file < 30mb) sharing service it's a bad idea? – Mher Didaryan Apr 07 '14 at 17:45
  • doesn't matter how big/small. if you want to protect direct access to the files, then just don't put them inside your side's document root. putting them into the db is a huge waste - consider 100 people all downloading the same file - you have to suck the SAME file out of your database 100 times. – Marc B Apr 07 '14 at 18:04
  • @MarcB probably shouldn't bog a newbie down in that just yet :) – Sammaye Apr 07 '14 at 18:06

1 Answers1

0

It is the path to whatever file your putting in, in this case it will be the tmp_name path from PHP $_FILES array

Sammaye
  • 43,242
  • 7
  • 104
  • 146