Laravel 4.2 Uploading file in specific folder
<p>Hi im creating a project in laravel 4.2 that uploads different files (e.g Pdf and images) in specific folders about 8 or 9 folders to be exact i just try the do a if statement but dont know what happend but its not working and there are no error displayed when i execute the code. please help me work this code or do you have any idea to simplify my code TIA!</p>

<p>Here's my code in my controller </p>

<pre><code>public function upload()
    {
        $finame = Input::get('name');
        $ftype = Input::get('type');
        $username = Input::get('user');
        $desc = Input::get('desc');
        $date = Input::get('date');
        $upload = Input::file('file');
        $add = Files::upload2($finame,$ftype,$username,$desc,$date,$upload);


        if ($add == true &amp;&amp; $ftype == "pf") {
            $upload -&gt; move(public_path('pf'),$upload-&gt;getClientOriginalName());
            return \Response::json(array('success' =&gt; true));
            return Redirect::to('/home')-&gt;with('message', 'message|Record Successfully Added.');
        } elseif ($add == true &amp;&amp; $ftype == "sf") {
            $upload -&gt; move(public_path('sf'),$upload-&gt;getClientOriginalName());
            return \Response::json(array('success' =&gt; true));
            return Redirect::to('/home')-&gt;with('message', 'message|Record Successfully Added.');
        } } elseif ($add == true &amp;&amp; $ftype == "gale") {
            $upload -&gt; move(public_path('gale'),$upload-&gt;getClientOriginalName());
            return \Response::json(array('success' =&gt; true));
            return Redirect::to('/home')-&gt;with('message', 'message|Record Successfully Added.');
        } } elseif ($add == true &amp;&amp; $ftype == "advisory") {
            $upload -&gt; move(public_path('advisory'),$upload-&gt;getClientOriginalName());
            return \Response::json(array('success' =&gt; true));
            return Redirect::to('/home')-&gt;with('message', 'message|Record Successfully Added.');
        } else {
            return Redirect::back()-&gt;with('message', 'error|Error');
        }

    }
</code></pre>

<p>And my code in model:</p>

<pre><code>public static function upload2($finame,$ftype,$username,$desc,$date,$upload)
    {

        $files = new self;
        $files-&gt;file_name = $finame;
        $files-&gt;file_type = $ftype;
        $files-&gt;username = $username;
        $files-&gt;description = $desc;
        $files-&gt;date = $date;
        $files-&gt;upload = $upload-&gt;getClientOriginalName();
        try {
            $files-&gt;save();
        } catch (Exception $e) {
            dd($e);
        }
    }
</code></pre>

<p>and in the view add this script:</p>

<pre><code>&lt;script&gt;
var form = document.getElementById('upload');
var request = new XMLHttpRequest();

form.addEventListener('submit', function(e){
    e.preventDefault();
    var formdata = new FormData(form);

    request.open('post', '/upload');
    request.addEventListener("load", transferComplete);
    request.send(formdata);

});

function transferComplete(data){
    response = JSON.parse(data.currentTarget.response);
    if(response.success){
        document.getElementById('message').innerHTML = "File Successfully Uploaded!";
    }
}
&lt;/script&gt;
</code></pre>