check the spelling here
if($request->hasfile('feaured'))
also, i dont see you saving the filename to the model for either image?
How do I upload two separate image files to different file locations and save to database? Everything works fine but only the business_logo is uploaded. I have included my table and controller here for details. Please I need help.
Here is my table : Schema::create('basics', function (Blueprint $table) { $table->increments('id'); $table->string('business_name'); $table->string('tagline'); $table->text('about'); $table->string('business_logo')->default('uploads/logos/codeflex.png'); $table->string('location'); $table->string('business_email'); $table->string('business_phone'); $table->integer('category_id'); $table->integer('city_id'); $table->integer('user_id')->unsigned(); $table->text('services'); $table->text('products'); $table->string('featured')->default('uploads/logos/codeflex.png'); $table->string('slug')->nullable(); $table->softDeletes(); $table->timestamps(); });
my Controller:
if($request->hasfile('business_logo'))
{
$file = $request->file('business_logo');
$extension = $file->getClientOriginalExtension(); // getting image extension
$filename =time().'.'.$extension;
$file->move('uploads/logos/', $filename);
}
if($request->hasfile('feaured'))
{
$myfile = $request->file('featured');
$extension = $myfile->getClientOriginalExtension(); // getting image extension
$filename =time().'.'.$extension;
$myfile->move('uploads/featured_images/', $filename);
}
$basic->business_name = $request->business_name;
$basic->tagline = $request->tagline;
$basic->about = $request->about;
$basic->location = $request->location;
$basic->business_email = $request->business_email;
$basic->business_phone = $request->business_phone;
$basic->category_id = $request->category_id;
$basic->city_id = $request->city_id;
$basic->products = $request->products;
$basic->services = $request->services;
$basic->save();
Please or to participate in this conversation.