Answer the question
In order to leave comments, you need to log in
Why is the picture saved as a folder?
Good day, I have a question.
Uploading a picture to the server means this way
if( $blog -> save() )
{
mkdir( "upload_for_post/" . $blog -> id, 0777 );
if( $request -> hasFile( 'image' ) )
{
$file = $request -> file( 'image' );
$input[ 'image' ] = $file -> getClientOriginalName();
// dd($input[ 'image' ]);
$file -> move( public_path() . '/upload_for_post/' . $blog -> id . '/' . $input[ 'image' ] );
}
if( $validator -> fails() )
{
return redirect() -> route( 'posts' ) -> withErrors( $validator ) -> withInput();
}
return redirect() -> route( 'posts' ) -> with( 'status', 'Post added' );
}
Answer the question
In order to leave comments, you need to log in
The magic lies right here
Must be specified before$input[ 'image' ]
" , "
" . "
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question