简体   繁体   中英

“Undefined Index” Error with Laravel and Intervention Image

Here's my file upload button:

<input type="file" name="image" required>
<button class="uk-button uk-button-default" type="button" tabindex="-1">Select Image</button>

And here's the code handling the file:

$largeimage = Image::make($_FILES['image']['tmp_name'])->fit(1060,707)->stream('jpg');
Storage::put('public/works/' . md5($image . microtime()) . '_large.jpg', $largeimage);

You has to make a lot of changes. Its a terrible idea to store user info on public folder also Storage has as root folder the storage folder. You has to store it in storage folder

if($request->hasFile('image')){
    $image = $request->file('image');
    $largeimage = Image::make($image)->fit(1060,707)->encode('jpg');
    Storage::put('works/{md5(microtime())}.jpg', $largeimage);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM