Laravel not storing files from request

308
February 11, 2017, at 10:30 AM

I got form with file upload named "image". Form is working and i'm getting image but for some reason it's not stored. this is the code I use to store image:

$path = $request->image->store('storage/uploads');

before that I check

$request->hasFile('image')

and later I'm saving $path. Path is successfully saved and when i check it it's really storage/uploads/radnomid but there is no file

Answer 1

Make sure that you are including enctype of multipart/form-data. You can either add the attribute directly to your form, or you can add a 'files' => true if you are using the FORM helper.

This is the conventional way to use the upload function that comes with Laravel 5.

public function processForm(Request $request) 
{
    if( $request->hasFile('image') ) {
        $file = $request->file('image');
        // Now you have your file in a variable that you can do things with
    }
}
READ ALSO
Parse error: syntax error, unexpected '!' [duplicate]

Parse error: syntax error, unexpected '!' [duplicate]

This question already has an answer here:

357
Joining two tables with conditon

Joining two tables with conditon

I have a two tables, Table 1 : users with fields (id,fname,lname,is_online) and Table 2: friendships with fields (friendA,friendB,status)

275
Send and information to Asana from sql server via api asana php

Send and information to Asana from sql server via api asana php

I need to know how i can make an app how can sent information from a sql server database to asana and return from asana to a sql server

295
Error with types postgresql

Error with types postgresql

I'm trying to make a php file that gets several variables in this way: http://pluginssmart-coast

307