JavaScript Save path image with Ajax in Laravel save path image android,save path image,save image path

I can save all data varchar/text element from my form, but I can't save my path image.

Whats is wrong with my code?

Lets see my create.blade.php I can save value of var deadline but I can't save value of var path:

Form::open(array('url' => 'imagesLoker', 'files' => true))
    <form class="form-horizontal">
    <div class="box-body">
        <div class="form-group">
            {!!Form::label('Deadline Lowongan : ')!!}
            {!!Form::date('deadline',null,['id'=>'deadline','class'=>'form-control','placeholder'=>'Deadline Lowongan'])!!}
        </div>
        <div class="form-group">
            {!!Form::label('Image Lowongan : ')!!}
            {!!Form::file('path') !!}
        </div>
    </div><!-- /.box-body -->
</form>
{!!Form::close()!!}

This is my Controller:

public function store(Request $request)
    {
        Lowongan::create($request->all());
        return "data all";
    }

This is my Ajax to create the data:

$("#createLoker").click(function(){
    var datas = $('form').serializeArray();
    var route = "http://localhost:8000/lowongan";
    var token = $("#token").val();
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $.post(route,{
        deadline: $("#deadline").val(),
        path: $("#path").val()
    }).done(function(result){
        console.log(result);
    });
});

I don't know this is important or no to setting parse data in my Modal, but I just put this code in my Modal:

class Lowongan extends Model
{
    protected $table = 'Lowongan';
    protected $fillable = ['path','deadline'];

    public function setPathAttribute($path){
        $this->attributes['path']  = Carbon::now()->second.$path->getClientOriginalName();
        $name = Carbon::now()->second.$path->getClientOriginalName();
        \Storage::disk('local')->put($name, \File::get($path));
    }
}

And the last I set the directory to save the image. This is setting in the config/filesystem:

'disks' => [
        'local' => [
            'driver' => 'local',
            'root'   => public_path('imagesLoker'),
        ],

I can save the data deadline but no for image :( .. If there is any idea for how to save the image path, I will be pleased to know it.

Answer:1

In your form you have to allow file upload option in laravel like.

Form::open(array('url' => 'foo/bar', 'files' => true))

check the file upload section of laravel doc

Hope it helps..

Answer:2

const A = [1,2,3,4,5] const B = [6,7,8,9,10] const C = []; for (let j=0; j<A.length;j++){ C[j] = C[[A[j],B[j]] } I want to create a 2D array C such that C = [[1,6],[2,7],[3,8],[4,9],[...

const A = [1,2,3,4,5] const B = [6,7,8,9,10] const C = []; for (let j=0; j<A.length;j++){ C[j] = C[[A[j],B[j]] } I want to create a 2D array C such that C = [[1,6],[2,7],[3,8],[4,9],[...

  1. create array from string
  2. create array from list
  3. create array from object
  4. create array from list python
  5. create array from number
  6. create array from 1 to n python
  7. create array from set javascript
  8. create array from string java
  9. create array from csv python
  10. create array from range vba
  11. create array from object values
  12. create array from string python
  13. create array from dataframe
  14. create array from 0 to n python
  15. create array from arraylist java
  16. create array from json
  17. create array from csv powershell
  18. create array from object keys
  19. create array from array javascript
  20. create array from string bash

I've got multiple items, some of them with the same title. I want to create an multidimensional array with the title as the first key and a unique number as the second key. So it's possible to ...

I've got multiple items, some of them with the same title. I want to create an multidimensional array with the title as the first key and a unique number as the second key. So it's possible to ...

  1. group array based on value javascript
  2. group array based on values php

So I have this example as shown below and I was wondering if its possible to translate a camera by changing the radius & diameter instead of using x,y,z positions (Vector). For now im using a cube ...

So I have this example as shown below and I was wondering if its possible to translate a camera by changing the radius & diameter instead of using x,y,z positions (Vector). For now im using a cube ...

  1. translating with camera
  2. translation with camera app
  3. camera translation in hindi
  4. camera translation in kannada
  5. camera translation and rotation
  6. camera translation from italian
  7. camera translation to japanese
  8. camera translation in different languages
  9. camera translation in spanish
  10. camera translation in nepali
  11. camera translation to russian
  12. chinese translator camera
  13. camera translation to arabic
  14. camera translation in swahili
  15. camera translation in malay
  16. translation for camera da letto
  17. camera translation in other languages
  18. camera translation to portuguese
  19. camera translation in gaelic
  20. text translate camera

I have a long form with a submit button that sends the values of all the fields into the address bar. However, I want the submit button to ALSO add an extra value (&submitted=yes) when it is ...

I have a long form with a submit button that sends the values of all the fields into the address bar. However, I want the submit button to ALSO add an extra value (&submitted=yes) when it is ...

  1. make submit button bigger
  2. make submit button not refresh page
  3. make submit button look like link
  4. make submit button send form to email
  5. make submit button disabled
  6. make submit button html
  7. make submit button disappear when clicked
  8. make submit button an image
  9. make submit button link to page
  10. make submit button unclickable
  11. make submit button
  12. make submit button hidden
  13. make submit button not clickable
  14. make submit button invisible
  15. make submit button do nothing
  16. make submit button a link
  17. make submit button javascript
  18. make submit button refresh page
  19. make submit button default enter
  20. make submit button work