can you show us your code as without that its quite difficult to answer your question
upload_form.php
<form action="/upload" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
Product name:
<br />
<input type="text" name="name" />
<br /><br />
Product photos (can attach more than one):
<br />
<input type="file" name="photos[]" multiple />
<br /><br />
<input type="submit" value="Upload" />
</form>
UploadController.php
class UploadController extends Controller
{
//
public function uploadForm()
{
return view('upload_form');
}
public function uploadSubmit(Request $request)
{
$product = Product::create($request->all());
foreach ($request->photos as $photo) {
$filename = $photo->store('photos');
ProductsPhoto::create([
'product_id' => $product->id,
'filename' => $filename
]);
}
return 'Upload successful!';
}
}
routes.php
Route::get('/upload', 'UploadController@uploadForm');
Route::post('/upload', 'UploadController@uploadSubmit');
I would try dd($request->all()) in the first line of uploadSubmit to see what is getting posted.
Or debug in Chrome or Xdebug.
Mick
The url turn into http://localhost/upload after pressing the upload button.
and:
Object not found!
public function uploadSubmit(Request $request)
{
dd($request->all());
$product = Product::create($request->all());
foreach ($request->photos as $photo) {
$filename = $photo->store('photos');
ProductsPhoto::create([
'product_id' => $product->id,
'filename' => $filename
]);
}
return 'Upload successful!';
}
Please or to participate in this conversation.