图片上的临时文件夹,以便上传:
#Get the path to the uploaded img
$filePath = Input::file('imgInp')->getRealPath();
$fileName = Input::file('imgInp')->getClientOriginalName();
$extension = Input::file('imgInp')->getClientOriginalExtension();
#Lets add the extension to the file name
$fileNameWithExtension = $fileName . '.' . $extension;
#Create the folder img/uploaded on your public folder!
$destination = public_path('img/uploaded/' . $fileNameWithExtension);
#Copy the img to your desired destination
#copy ($filePath, $destination);
#Instead of the copy function you can use this laravel function
Input::file('imgInp')->move($destination);
#Save on database the path to your img
$admin = Admin::find(25);
$admin->picture = $destination;
$admin->update();
我希望它的作品。没试过
然后,如果你想展示你的形象只是做到以下几点:
$admin = Admin::find(25);
#Pass the variable to your view and them, if you use blade templating system:
<img src="{{asset($admin->picture)}}">
#If you are not using blade do it this way
<img src="<?php echo asset($admin->picture); ?>">
任何错误/异常? –
@André我已经在问题中说过我已经尝试了' - > save()',但没有任何内容保存到我的数据库中 –
您不应该在数据库中存储任何作为base64的图像。只需将img保存到资产文件夹并将路径存储到img即可。 –