Skip to content
Advertisement

Why doesn’t my php laravel application store my image?

I’ve looked at code from other people and try to implement the same thing, but the application could not store the image to the desire folder, would you please have a look at what the reason is? Thank you! Here is my code for route:

JavaScript

Here is my code for the php laravel template:

JavaScript

Here is my code in the controller:

JavaScript

Advertisement

Answer

Your problem is somewhere here

JavaScript
  • First, the file comprises only the file extension. Instead, you should have something like this $filename = 'name.' . $file->getClientOriginalName(); Notice the dot in 'name.'
  • Secondly, no need to add public to the file path string. So it should be $file->move(public_path('img/student_photos'),$filename);
  • Finally, make sure the upload folder exists and is writeable
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement