1

i am a novice in laravel and this is going to be a very basic question.

I am working a on a simple project using Laravel4.I have a model namely image.In fact through this model i will store uploaded image and the information associated with that image.But i don't know what should be column type or data type for image field in the migration file.

migration file:

 Schema::create('images', function(Blueprint $table)
    {
        $table->increments('id');

        $table->string('name',255);
        $table->------('image');
        $table->timestamps();
    });

you can see that in my above migration file,i have remain empty the image field.I don't know what should be the column type for image field.

so what should be column type or the data type for a image field in laravel4 migration file?

Tanveer
  • 291
  • 3
  • 6
  • 15
  • [Don't store images in a database](http://stackoverflow.com/questions/815626/to-do-or-not-to-do-store-images-in-a-database), instead use just a string column to store the path to the image on the filesystem. –  Aug 22 '14 at 16:14

1 Answers1

0

Yes, you shouldn't be storing an image in database.

Instead in you public folder, create a file folder and store all your images in a folder named userphotos or something similar

When you receive image from the user, you should be extracting the image name and store it in your database. To differentiate , you could append timestamp for uniqueness of name of file.

So ideally your migration should have string datatype and nothing else.

Hope this helps!!

Yashaswini
  • 49
  • 5