上传公共文件夹中的图像

时间:2017-11-19 07:03:05

标签: laravel laravel-5.4

我正在尝试使用laravel 5.4在数据库中插入图像。有用。但是,当我搜索该目录时,它不会出现在那里。我也想验证只有图片应该上传和大小。 谢谢你的进步。

我的控制器功能在这里

Private Sub Worksheet_Change(ByVal Target As Range)

Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Long

Set WorkRng = Intersect(Application.ActiveSheet.Range("H:H"), Target)
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
  Select Case Rng.Value2
    Case "Not-initiated"
      xOffsetColumn = 100  'Column O
    Case "Adv/Sourcing"
      xOffsetColumn = 9  'Column U
    Case "Interviewing"
      xOffsetColumn = 10  'Column Q
    Case "Offering & Selection"
      xOffsetColumn = 11  'Column R
    Case "Onboarding"
      xOffsetColumn = 12  'Column S
    Case "Contract Signed"
      xOffsetColumn = 13  'Column U
    Case "Joined"
      xOffsetColumn = 14  'Column Q
    Case Else
      xOffsetColumn = 101  'Column T - entry not listed above
  End Select
  Rng.Offset(0, xOffsetColumn).Value = Now
  Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy"
Next
Application.EnableEvents = True
End If
End Sub

2 个答案:

答案 0 :(得分:3)

试试这个:

// Validation
$this->validate($request, [
   'image' => 'required|image|mimes:jpeg,bmp,png|max:10240' // size in kelobytes this equals 10 mb
]);

 $User = new User() ;
 $User->password = bcrypt($request->password);
 $User->name = $request->name;
 $User->type = $request->type;
 $User->email = $request->email;
 $filename = $this->getFileName($request->image);
 $request->image->move(base_path('public/images'), $filename);
 $User->image = $fileName;
 $$User->save();
 return back()->with('success','Image Upload successful');

我只是忘了向您展示如何实现getFileName函数来生成唯一的文件名抱歉,在您的控制器中,您可以将其定义为受保护的方法,如下所示:

protected function getFileName($file)
{
   return str_random(32) . '.' . $file->extension();
}

答案 1 :(得分:0)

我认为你正试着像这样做:

{{1}}