Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

send image in request body laravel 6

public function uploadTest(Request $request) {

    if(!$request->hasFile('image')) {
        return response()->json(['upload_file_not_found'], 400);
    }
    $file = $request->file('image');
    if(!$file->isValid()) {
        return response()->json(['invalid_file_upload'], 400);
    }
    $path = public_path() . '/uploads/images/store/';
    $file->move($path, $file->getClientOriginalName());
    return response()->json(compact('path'));
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #send #image #request #body #laravel
ADD COMMENT
Topic
Name
7+7 =