Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Showing posts with label mongodb. Show all posts
Showing posts with label mongodb. Show all posts

Tuesday 23 April 2013

mongodb upload image using php

mongodb upload image using php
Categories :- What is Mongodb  Install Mongo on CentOS,Fedora, Ubuntu & Debian


Introduction : - In My privous article i have explained  What is Mongodb
GridFS is a specification for storing large files in MongoDB. In this post I will explain how you can easily upload a file to GridFS and then retrieve it from the database to serve it to the browser

The name of the uploaded file to store. This should correspond to the file field's name attribute in the HTML form
<html>
<body>
<!--The name of the uploaded file to store. This should correspond to the file field's name attribute in the 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>

</html></body>

If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:

<?php
error_reporting(0); //// Turn off all error reporting
//If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:
$m = new MongoClient();
$gridfs = $m->selectDB('test')->getGridFS();

$gridfs->storeUpload('pic', array('username' => $_POST['username']));
echo 'File Uploaded Successfully';

?>

Complete Code As Show Below

<!-- image and any file  uploaded  in mongodb -->
<html>
<body>
<!--The name of the uploaded file to store. This should correspond to the file field's name attribute in the 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>

</html></body>

<?php
error_reporting(0); //// Turn off all error reporting
//If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:
$m = new MongoClient();
$gridfs = $m->selectDB('test')->getGridFS();

$gridfs->storeUpload('pic', array('username' => $_POST['username']));
echo 'File Uploaded Successfully';

?>

Running output Image Screen Short As shown Below
1-> Run the Fie then

2-> when insert the Name and Browse the Image Screen Short As Show Below

3-> When Click on Submit  Query Button Get the Message (File Uploaded Successfully)


 4-> Check the Out In Database Image is Save or not open the genghis phpadmin then output as shown below




Download sample code attached



Wednesday 20 March 2013

what is mongodb

what is mongodb

what is mongodb

MongoDB is the leading NoSQL database, designed for how we build and run applications today. MongoDB empowers organizations to be agile and scalable. It helps them enable new types of applications, improve customer experience, accelerate time to market and reduce total cost of ownership (TCO).
MongoDB is a general purpose, open-source database. MongoDB features:
  • Document data model with dynamic schemas
  • Full, flexible index support and rich queries
  • Auto-Sharding for horizontal scalability
  • Built-in replication for high availability
  • Text search
  • Advanced security
  • Aggregation Framework and MapReduce
  • Large media storage with GridFS
  •  

 MongoDB is an open-source, high-performance, document-oriented database. Documents are JSON-like data structures stored in a format called BSON (bsonspec.org). Documents are stored in collections, each of which resides in its own database. Collections can be thought of as the equivalent of a table in an RDBMS. There are no fixed schemas in MongoDB, so documents with different “shapes” can be stored in the same collection. 

MongoDB features full index support (including secondary and compound indexes); indexes are specified per collection. There is a rich, document-based query language (see reverse) that leverages these indexes. MongoDB also provides sophisticated atomic update modifiers (see reverse) to keep code contention-free. 

Clustered setups are supported, including easy replication for high availability, as well as auto-sharding for write-scaling and large data-set sizes.

Organizations of all sizes use MongoDB to quickly and easily develop, scale and operate applications. Instead of storing data in rows and columns as one would with a relational database, MongoDB stores a binary form of JSON documents (BSON).

Dev’Backup/Restore
MongoDB ability to dumpadb/collection empowers developer
Possible to restore part of the production data set simply on a development box
Backup a MongoDB by collections in S3,recoverondev’platform in a matter of minutes
What we expect from our NoSQLDBMS and our compromise No downtime
:Hig havailability
No migrationcost Easy to deploy,redeploy,replicate,reconfigure
Quietly losing seconds of writes is preferable to weekly minutes-long maintenances periods
minutes-long unscheduled downtime and manual failover in case of hardware failure.

About MongoDB

MongoDB is a document-oriented database and each document has its own structure. Unlike a RDBMS in which each record must conform to the structure of its table, each document in MongoDB can have a different structure; you don’t have to define a schema for documents before saving them in the database.
MongoDB groups document objects into collections. You can think of a collection as a table like you would create in a RDBMS, but the difference as I said before is that they won’t force you to define a schema before you can store something.

With MongoDB, you can embed a document inside another one, which is really useful for cases where there is a one-to-one relationship. In a typical RDBMS you’d need to create two tables and link them together with a foreign key to achieve the same result. MongoDB doesn’t support joins, which some people see as a con. But if you organize your data correctly then you’ll find you don’t need joins, which is a pro since you’ll benefit from very high performance.

It’s worth mentioning the aim of MongoDB and NoSQL isn’t to kill off RDBMS. RDBMSs are still a very good solution for most of the development world’s needs, but they do have their weaknesses, most noticeably the need to define a rigid schema for your data which is one problem NoSQL tries to solve.

Example is Coming Soon Related to MongoDB
 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result