java上传文件文件保存后损坏_Laravel存储文件在上传时会损坏
這是出于信息目的,因為她已經要求采用另一種方式 . 無需向上或向下拇指 .
public function store(Request $request){
$this->validate($request, array(
// I have done the validations but skip to show it here
// OBTAINING THE IMAGES
$files = $request->images;
// COUNTING HOW MANY WERE RECEIVED
$file_count = count($files);
// INITIALIZING A COUNTER
$uploadcount = 0;
foreach($files as $file) {
$filename = $file->getClientOriginalName();
$temporary = public_path(). '/uploads/temporary/' . $property->id;
if(!file_exists($temporary)) File::makeDirectory($temporary);
$temp = $file->move($temporary, $filename); // This is where they temporary stay to be fetched for processing
$thumbs = public_path(). '/uploads/thumbs/' . $property->id;
if(!file_exists($thumbs)) File::makeDirectory($thumbs);
Image::make($temp)->resize(240,160)->save($thumbs . '/' . $filename);
// We are setting up another directory where we want to save copies with other sizes
$gallery= public_path(). '/uploads/gallery/' . $property->id;
if(!file_exists($gallery)) File::makeDirectory($gallery);
Image::make($temp)->resize(400,300)->save($gallery . '/' . $filename);
$picture = new Picture;
$picture->property_id = $property->id;
$picture->name = $filename;
$picture->save();
$uploadcount ++;
}
if($uploadcount == $file_count){
Session::flash('success', 'Upload successfully');
return Redirect()->route('property.show', $property->id);
}
else{ Session::flash('errors', 'screwed up');
return Redirect::to('upload')->withInput()->withErrors($validator);
}
}
總結
以上是生活随笔為你收集整理的java上传文件文件保存后损坏_Laravel存储文件在上传时会损坏的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java截取字符串拼接_java截取字符
- 下一篇: 女生身体不适没给大爷让座遭怒骂 互拍互怼