Wednesday, April 17, 2019

Upload multiple images in Laravel 5.6

Are you using Laravel? Do you want to upload multi images in Laravel? There are multi way and code to upload images with Laravel. On this article, I would like to show you how to upload multi images using bootstrap fileinput plugin on Laravel 5.6 application. You can do on this style such as upload multi images, zoom images, and remove images by using bootstrap fileinput plugin. One more thing, you can customize font size too. What is bootstrap fileinput? Bootstrap fileinput is a bootstrap plugin. Advantage of bootstrap file is upload multi images and dropzone.

Step 1: please download style and script from this path Style and Script

step 2: copy into public folder or you can upload it into your hosting. On this, I will show you style upload to hosting.



  • public folder


    • into your hosting

    Step 3: create blade PHP file
    You need to create blade file on path “resource/view/uploadmulti.blade.php”

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link href="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/bootstrap.min.css" rel="stylesheet">
        <link href="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/fileinput.css" media="all" rel="stylesheet" type="text/css"/>
        <link href="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/font-awesome.min.css" media="all" rel="stylesheet" type="text/css"/>
        <style type="text/css">
            .main-section{
                margin:0 auto;
                padding: 25px;
                margin-top: 80px;
                background-color: #fff;
                box-shadow: 0px 0px 25px #c1c1c1;
            }
            .fileinput-remove,
            .fileinput-upload{
                display: none;
            }
        </style>
    </head>
    <body class="bg-danger">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-sm-12 col-11 main-section">
                <h1 class="text-center text-danger">upload Multi image</h1><br>

                {!! csrf_field() !!}
                <div class="form-group">
                    <div class="file-loading">
                        <input id="file-1" type="file" name="fileimg" multiple class="file" data-overwrite-initial="false" data-min-file-count="2">
                    </div>
                </div>

            </div>
        </div>
    </div>
    <script src="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/jquery-3.2.1.min.js"></script>
    <script src="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/fileinput.js" type="text/javascript"></script>
    <script src="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/theme.js" type="text/javascript"></script>
    <script src="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/umd/popper.min.js" type="text/javascript"></script>
    <script src="http://www.dada.com.kh/DaWebsit/syleAndJSuploadImg/bootstrap.min.js" type="text/javascript"></script>


    <script type="text/javascript">
        $("#file-1").fileinput({
            theme: 'fa',
            uploadUrl: "/uploadImg",
            uploadExtraData: function() {
                return {
                    _token: $("input[name='_token']").val(),
                };
            },
            allowedFileExtensions: ['jpg', 'png', 'gif'],
            overwriteInitial: false,
            maxFileSize:2000,
            maxFilesNum: 5,
            slugCallback: function (filename) {
                return filename.replace('(', '_').replace(']', '_');
            }
        });
    </script>


    </body>
    </html>

    Step 4: create Routes on path “Routes/Web.php”

    Route::get('uploadImg,'ImageController@index');
    Route::post('uploadImg','ImageController@store');

    Step 5: create controller “app/http/controllers/ImageController.php”

    <?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    class ImageController extends Controller
    {
        /**
         * success response method.
         *
         * @return \Illuminate\Http\Response
         */
        public function index()
        {
            return view('uploadImg');
    }


    /**
     * success response method.
     *
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $imageName = request()->fileimg->getClientOriginalName();
        request()->fileimg->move(public_path('upload'), $imageName);
        return response()->json(['uploaded' => '/upload/'.$imageName]);
    }
    }


    Monday, April 15, 2019

    The best way to improve your relationship with co-worker

    Indeed, you probably spend many times at workplace especially with co-worker than with other people because you need to connect relationship to work together everyday. It is very essential that you need to make decent relationship with them. Actually, if you have harmonious with co-worker, it can make process of work better. If you want to success with your work, you need to make good relationship with co-worker because they can help to improve you capacity such as sharing good idea, experience, and find solution to solve problem. On the follow points, you will learn how to improve relationship with co-worker at workplace.

    1- Respect your co-worker
    Although, you don't have to be close friend with all of your co-worker but you should demonstrate respect for them. The basic ways avoid conflict with co-worker is to do avoid doing offensive thing.
    For example: if you want to borrow something from them, you should inform to them avoid take without don't tell.

    2- Choose topic to say with them
    It is very good thing if you become close friend with co-worker to relationship together. But you must take care about taking topic to talk with them because some topic or word can effect with their feel. For example: you are talking about religion and you criticize some religion which it is your colleagues’ religion respected. So it can make conflict between you and co-worker. One more thing, you should not say about discriminate​​ politics or party, nationality, religion, discriminate other that it can make conflict at workplace.

    3- Start to create good relationship
    When you just to start new job on the company that have a lot of people work on here. Indeed, you always feel to worrying about impressing from your boss. Also you will concern about establishing rapport with your co-worker. Will you can get along with them as well as? Building good relationship need to take time and it will start on the first day of your work. On the first day of work, you should start by being friendly to other people you meet. If you don't say Hello, your smile is very good for you.

    4- Try to find way to get along with other people
    Character of people is different from one person to one person, so you need to find the way to connect relationship with them even they are difficult people to talk. For example: you can start to talk with them about this thing or those things. You should try to ask about status of work. Can you help them? You often try like this. You will create relationship with them very well.

    5- Be kind to your co-workers

    You should help your co-worker all time when they meet some problem and they need helper from other. Also you should perform actions of kindness. Helping is good action to create best relationship at work place. Relationship is more better if you are a kind to your co-worker.