Hello, I have a small problem, I followed Jeffrey's tutorial on how to ajaxify the image upload system for a users profile, but I have an error on uploading a file. It for some reason says.
The 422 is likely a validation failure - you should be able to see more information about the request and response inside your Network tab in the browser's Developer tools. The commented line means a request is not made, so the validation can't be executed.
{message: "The given data was invalid.", errors: {avatar: ["The avatar must be an image."]}}
errors
:
{avatar: ["The avatar must be an image."]}
avatar
:
["The avatar must be an image."]
message
:
"The given data was invalid."
I don't get it, I uploaded an image but it says it is invalid. I added this to my input file, Maybe this has something to do with it?
You might also have an issue with the relative file path used for the image src - see how it expects to find the image in a profiel directory (I assume this is the current URI). You should use an absolute path an specify the full path relative to the image having the public directory as root.
I never specified it needed to look in a profiel directory, Can you show me an example of what you mean? of for instance, where to specify the full path?
Okay, I got it working now. But there is one small minor problem which you may know. If a user did not set a profile picture it is supposed to show a placeholder but instead, it doesn't show anything and the URL says /storage/null. I've made a IF statement which does that very thing but somehow it does not work correctly. This is the if statement: