if (/* something *) {
$image_name = 'something else';
}
if it doesn't pass your if statement the image_name is never defined (as the error already told you).
There is no file being uploaded in your sample. And I think you want to move the Style::create() inside the if statement. If no file is being uploaded it shouldn't create a new style I suppose?
If you pay me my hourly rate, yes I could do that.
But you should be able to figure this out. Read the error again: "Undefined variable: image_name". What does this mean? The variable $image_name is not defined. So you have to figure out why is this happening and when? Looking at your code it can happen if there is no file uploaded (see the if statement).
That means the image is not uploaded so php won't execute your if block.
make sure that you upload the image correctly, or as temporary solution you can define the variable before the if statement like this: