php - Laravel 5.2 'The file "Cover.jpg" was not uploaded due to an unknown error.' -


i using laravel 5.2 , got error.

fileexception in uploadedfile.php line 235: file "cover.jpg" not uploaded due unknown error.      1. in uploadedfile.php line 235 @ uploadedfile->move('productimages', '20160808094822_a3f390d88e4c41f2747bfa2f1b5f87db.jpg')    2. in productcontroller.php line 144 

my code:

public static function imageupload(request $request, $productid, $type = 'image') {         /* set file destination */         $destination = 'productimages';          if ($request->hasfile('cover') or $request->hasfile('images')) {              /* single file - cover */             if ($request->hasfile('cover')) {                 $filename = date('ymdhis') . '_' . md5($productid) . '.jpg';                  $filepath = "/" . $destination . "/" . $filename;                  $prodimage = new product_images;                 $prodimage->productid = $productid;                 $prodimage->imagepath = $filepath;                 $prodimage->cover = ($type == 'cover' ? 'yes' : 'no');                 $prodimage->save();                  if ($request->file('cover')->move($destination, $filename)) {                     echo "success";                 }                 else {                     echo "error";                 }             }              /* process multiple files */             if (count($request->file('images')) > 0) {                 foreach ($request->file('images') $image) {                     $filename = date('ymdhis') . '_' . md5($image->getclientoriginalname()) . '.jpg';                      $filepath = "/" . $destination . "/" . $filename;                      $prodimage = new product_images;                     $prodimage->productid = $productid;                     $prodimage->imagepath = $filepath;                     $prodimage->cover = ($type == 'cover' ? 'yes' : 'no');                     $prodimage->save();                      $image->move($destination, $filename);                 }             }         }        if ($request->hasfile('images')) {         self::imageupload($request, $product->id);     }     if ($request->hasfile('cover')) {         self::imageupload($request, $product->id, 'cover');     } 

the statement

  if ($request->file('cover')->move($destination, $filename)) {                 echo "success";             }             else {                 echo "error";             } 

always returns "success", function returns 'true' laravel throws error. same function 'move' in loop doesn't return error. images successful uploaded , moved.

i having same issue because not giving complete path destination folder

if (input::file('product_image')->isvalid()) {             $extension = input::file('product_image')->getclientoriginalextension(); // getting image extension             $filename = $unique_prefix . rand(11111,99999).'.'.$extension; // renameing image             input::file('product_image')->move(public_path().$destinationpath, $filename); // uploading file given path             dd(public_path().$destinationpath);         } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -