No idea why file is not uploading.

Posted 6 months ago by seamuswc


namespace App;

use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class product extends Model
  public function create(Request $request) {
    $file = $request->file('photo');
    if ( $request->hasFile('photo') && $request->file('photo')->isValid() ) 
      $extension = $file->extension();
      $name = 'bjdsakbhdebkhdabhkedbhe'.$extension;
      $path = $file->storeAs('public/images',$name);
    else {
      return 'error';

  'photo' => $path,    


protected $fillable = ['name', 'price', 'roast', 'origin', 'photo', 'stock'];



namespace App\Http\Controllers;

 use Illuminate\Http\Request;
 use App\product;

use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;

class adminController extends Controller
  public function __construct() {

  public function create(Request $request) {

   ini_set('max_execution_time', 300);

   $validatedData = $request->validate([
     'photo' => 'required|file|image'

  $new = new product;


I am trying to upload a file image. I have reworked the above code several times and an error is thrown. Absolutely NO idea why the file is not uploading. It is not a server error. File size and time allowed have been adjusted.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.