0

i want to upload file , this is my controller :

$uploadFile = $request->file("document");
dd($request->file("document"));
$path = $uploadFile->store('storage/files');

this is my form action :

<form class="form-horizontal" action="{{route('mto-post')}}" method="post" enctype="multipart/form-data" files="true">
    {{ csrf_field() }}

..........................................

<td class="pt-3-half">
    <div class="form-group">
        <label for="document">Document</label><br>
        <input type="file" name="document">
        <small class="form-text text-muted">Harap Masukan Featured Image Yang Ingin Digunakan.</small>
    </div>

but , when i dd($request->file("document"));

is always return NULL

this is results $request->input()

   array:13 [▼
  "_token" => "P3jR5AzMe4jPPeEud24Tdue0LPOc1zFcgR5viEcW"
  "txtWorkOrder" => "23iy4837t5"
  "txtDocNumber" => "34iwugru3j4gr4u"
  "txtLocation" => "8327y8"
  "tanggal" => "2019-04-08"
  "txtItemCode" => array:3 [▶]
  "txtDescription" => array:3 [▶]
  "txtSpek" => array:3 [▶]
  "txtUnits" => array:3 [▶]
  "Cat" => array:3 [▶]
  "txtRequiredQty" => array:3 [▶]
  "txtSpareQty" => array:3 [▶]
  "action" => "draft"
]

whats wrong about my code ? any help will be appreciated. Thanks

Bian
  • 95
  • 2
  • 10
  • You don't need the `files="true"` attribute I believe. Are you selecting a file to upload? can you show the full controller function? – nakov Apr 29 '19 at 07:50
  • yes , i selecting file when uploading,, i already remove files="true", but still not working this is my full controller action https://pastebin.com/fwmUqpEz – Bian Apr 29 '19 at 07:54
  • I assume this form is just being submitted natively i.e. without javascript? Are you able to show the output of `dd($request->input());`? – Rwd Apr 29 '19 at 07:57
  • this form using javascript ajax and jquery – Bian Apr 29 '19 at 08:00
  • can you upload your ajax function ?? – Md.Sukel Ali Apr 29 '19 at 08:05
  • [here](https://stackoverflow.com/a/2320097/1457270) an answer for using file upload using ajax. – nakov Apr 29 '19 at 08:11

0 Answers0