我想基于application_id
重命名文件,但是要放一个点,例如.jpeg
,这可能是问题所在。
这是我的控制器文件。
public function uploadImages(Request $request)
{
$applications = new Applications;
$applications_id = Input::get('applications_id_unique_field');
$applications->applications_id = Input::get('applications_id_unique_field');
$imgName = "$applications->applications_id" .'.' . $request->breg_cert->getClientOriginalExtension();
request()->breg_cert->move(public_path('breg_cert'), $imgName);
$applications->breg_cert = $imgName;
// dd($applications->KRAPIN);
return response()->json(['uploaded' => '/breg_cert/'.$imgName]);
}
我在javascript.bootstrap文件输入代码。这控制了我的bootsrap文件输入。
<script>
$("#file-0a").fileinput({
showUpload: true,
showRemove: true,
showCaption: true,
showPreview: true,
showClose: false,
autoOrientImage: true,
showUploadedThumbs: false,
uploadAsync: false,
uploadUrlThumb: false,
deleteUrl: "/public/KFS_Business_Registration_Certificates",
uploadUrl: "{{route('image.upload')}}",
// uploadUrl: '/public/KFS_Business_Registration_Certificates', // you must set a valid URL here else you will get an error
theme: 'fa',
uploadExtraData: function() {
return {
_token: "{{ csrf_token() }}",
};
},
allowedFileExtensions: ['jpg', 'png', 'gif', 'pdf', 'jpeg'],
overwriteInitial: false,
maxFileSize: 500,
maxFilesNum: 10,
//allowedFileTypes: ['image', 'video', 'flash'],
slugCallback: function (filename) {
return filename.replace('(', '_').replace(']', '_');
}
});
</script>