【问题标题】:how to upload a pdf document in Laravel如何在 Laravel 中上传 pdf 文档
【发布时间】:2021-04-09 11:23:08
【问题描述】:

如何在 Laravel 中上传 pdf 文档,字段名称为 RESUME 和文件夹 create din PUBLIC->RESUME

protected function create(array $data)
{
    $file_extention = $data['RESUME']->getClientOriginalExtension();
    $file_name = time().rand(99,999).'RESUME.'.$file_extention;
    $file_path = $data['RESUME']->move(public_path().'/users/image',$file_name);

    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'mobile' => $data['mobile'],
        'password' => Hash::make($data['password']),
        'file_path' => $RESUME
    ]);
          
    
}

【问题讨论】:

标签: php laravel


【解决方案1】:

我已经上传了一个文件名。如果您想将特定名称作为文件名,请更改 $file->storeAs($filePath, $fileName='RESUME', 'uploads');。如果您有任何疑问,请随时在下面发表评论。谢谢

protected function create(array $data){
 $request = request();

 $profileImage = $request->file('resumes');
 $profileImageSaveAsName = time() . Auth::id() . "-profile." . $profileImage->getClientOriginalExtension();

 $upload_path = 'resumes/';
 $resumes= $upload_path . $profileImageSaveAsName;
 $success = $profileImage->move($upload_path, $profileImageSaveAsName);


  return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'dob' => $data['dob'],
        'resumes' => $resumes,
    ]);
}

【讨论】:

  • 我可以像这个 Rashed Zaman 一样粘贴吗
  • 如果我这样说它的显示错误 Rashed Zaman
  • 你能用完整的代码 Rashed Zaman 分享 WhatsApp 号码
猜你喜欢
  • 2021-02-02
  • 2020-06-22
  • 2020-05-10
  • 1970-01-01
  • 2015-09-23
  • 1970-01-01
  • 1970-01-01
  • 2016-08-11
  • 2020-01-23
相关资源
最近更新 更多