Guest User

Untitled

a guest
May 27th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. if($request->hasFile('image1')){
  2. // Get filename with the extension
  3. $filenameWithExt = $request->file('image1')->getClientOriginalName();
  4. // Get just filename
  5. $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
  6. // Get just ext
  7. $extension = $request->file('image1')->getClientOriginalExtension();
  8. // Filename to store
  9. $fileNameToStore= $filename.'_'.time().'.'.$extension;
  10. // Upload Image
  11. $path = $request->file('image1')->storeAs('public/cover_images', $fileNameToStore);
  12. } else {
  13. $fileNameToStore = 'noimage.jpg';
  14. }
  15.  
  16. public function up()
  17. {
  18. Schema::table('images', function ( $table) {
  19. $table->string('image1');
  20. $table->string('image2');
  21. $table->string('image3')->nullable();
  22. $table->string('image4')->nullable();
  23. $table->string('image5')->nullable();
  24. $table->string('image6')->nullable();
  25. $table->string('image7')->nullable();
  26. $table->string('image8')->nullable();
  27. $table->string('image9')->nullable();
  28. $table->string('image10')->nullable();
  29. $table->string('image11')->nullable();
  30. $table->string('image12')->nullable();
  31. $table->string('image13')->nullable();
  32. $table->string('image14')->nullable();
  33. $table->string('image15')->nullable();
  34. $table->string('image16')->nullable();
  35. });
  36. }
Add Comment
Please, Sign In to add comment