0

I am wondering what to write in my laravel controller to allow me work with a pdf document posted from the front end by an AJAX request. I have found code online to check if an image is uploaded, but anyone have an idea what I need to do if it's a pdf document.

Please see my code below.

public function postUpload() {
    $file = Input::file('image');
    do something here.....     
}

1 Answer 1

1

An example from documentation:

public function postUpload(Request $request) {
    if ($request->hasFile('file')) {
        $file = $request->file('file');
        do something here.....
    }
}

To check if file is PDF, use validation rules, like:

$rules  = [
    "file" => "mimes:pdf"
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.