Esempio n. 1
0
 public function thumbnail2(Request $request)
 {
     if ($request->hasFile('thumbnail_file2')) {
         $messages = ['photo.image' => '上传文件必须是图片', 'photo.max' => '上传文件不能大于:maxkb'];
         $this->validate($request, ['photo' => 'image|max:100000'], $messages);
         if ($request->file('thumbnail_file2')->isValid()) {
             $OriginalName = $request->file('thumbnail_file2')->getClientOriginalName();
             $file_pre = sha1(time() . $OriginalName);
             //取得当前时间戳
             $file_suffix = substr(strchr($request->file('thumbnail_file2')->getMimeType(), "/"), 1);
             //取得文件后缀
             $destinationPath = 'uploads';
             //上传路径
             $fileName = $file_pre . '.' . $file_suffix;
             //上传文件名
             Image::make($request->file('thumbnail_file2'))->resize(300, null, function ($constraint) {
                 $constraint->aspectRatio();
             })->save('uploads/thumbnails/' . $fileName);
             $request->file('thumbnail_file2')->move($destinationPath, $fileName);
             $img = new Img();
             $img->name = $fileName;
             $img->save();
             Session()->flash('img2', $fileName);
             return $fileName;
         } else {
             return "上传文件无效!";
         }
     } else {
         return "文件上传失败!";
     }
 }
 public function fileUpload(Request $request)
 {
     // return ($request->file('photo')->getMimeType());
     if ($request->hasFile('photo')) {
         $messages = ['photo.image' => '上传文件必须是图片', 'photo.max' => '上传文件不能大于:maxkb'];
         $this->validate($request, ['photo' => 'image|max:500'], $messages);
         if ($request->file('photo')->isValid()) {
             $file_pre = getdate()[0];
             //取得当前时间戳
             $file_suffix = substr(strchr($request->file('photo')->getMimeType(), "/"), 1);
             //取得文件后缀
             $destinationPath = 'uploads';
             //上传路径
             $fileName = $file_pre . '.' . $file_suffix;
             //上传文件名
             $request->file('photo')->move($destinationPath, $fileName);
             $img = new Img();
             $img->name = $fileName;
             $img->save();
             Session()->flash('img', $fileName);
             // return view('/admin/fileselect');
             return $fileName;
         } else {
             return "上传文件无效!";
         }
     } else {
         return "文件上传失败!";
     }
 }
Esempio n. 3
0
 public static function bannerImgClear($clearNum = 5, $clearTimeDiff = 5)
 {
     $res = 0;
     Img::orderBy('created_at', 'ASC')->where('img_block', '=', 'banner')->where('img_active', '=', '0')->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-{$clearTimeDiff} minute", strtotime(date("Y-m-d H:i:s")))))->take($clearNum)->delete();
     $imgs = Img::onlyTrashed()->take($clearNum)->get();
     foreach ($imgs as $img) {
         if (file_exists(public_path() . $img->img_hd)) {
             unlink(public_path() . $img->img_hd);
         }
         if (file_exists(public_path() . $img->img_big)) {
             unlink(public_path() . $img->img_big);
         }
         if (file_exists(public_path() . $img->img_small)) {
             unlink(public_path() . $img->img_small);
         }
         if (file_exists(public_path() . $img->img_tiny)) {
             unlink(public_path() . $img->img_tiny);
         }
         if (file_exists(public_path() . $img->img_square)) {
             unlink(public_path() . $img->img_square);
         }
         if (!file_exists(public_path() . $img->img_hd) && !file_exists(public_path() . $img->img_big) && !file_exists(public_path() . $img->img_small) && !file_exists(public_path() . $img->img_tiny)) {
             $img->forceDelete();
             $res = 1;
         }
     }
     return $res;
 }
Esempio n. 4
0
 public function getEdit(Request $request, $banner_id)
 {
     $banner = Banner::findOrFail($banner_id);
     $perpage = 12;
     $imgs = Img::where('img_block', '=', 'public')->orderBy('created_at', 'DESC')->simplePaginate($perpage);
     return view('manage.banner.edit', ['TITLE' => '轮播编辑', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => '/manage/banner/edit', 'banner' => $banner, 'imgs' => $imgs]);
 }
Esempio n. 5
0
 public function getEdit(Request $request, $activity_id)
 {
     $activity = Activity::findOrFail($activity_id);
     $perpage = 12;
     $imgs = Img::where('img_block', '=', 'public')->orderBy('created_at', 'DESC')->simplePaginate($perpage);
     return view('manage.activity.edit', ['TITLE' => '活动编辑', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => '/manage/activity/edit', 'activity' => $activity, 'imgs' => $imgs]);
 }
Esempio n. 6
0
 public function getEdit(Request $request, $product_id)
 {
     $product = Product::findOrFail($product_id);
     $perpage = 12;
     $imgs = Img::where('img_block', '=', 'public')->orderBy('created_at', 'DESC')->simplePaginate($perpage);
     return view('manage.product.edit', ['TITLE' => '活动编辑', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => '/manage/product/edit', 'product' => $product, 'imgs' => $imgs]);
 }
Esempio n. 7
0
 public function getIndex(Request $request)
 {
     User::createTable();
     // User::createAdmin('*****@*****.**','adminadmin123');
     Img::createTable();
     Mylog::createTable();
     Banner::createTable();
     Product::createTable();
 }
Esempio n. 8
0
 public function anyGet(Request $request, $img_block = 'all')
 {
     $res = ['response' => 'YES', 'status' => 1, 'imgs' => []];
     $perpage = 20;
     $imgs = Img::orderBy('created_at', 'DESC');
     if ($img_block != 'all') {
         $imgs = $imgs->where('img_block', '=', $img_block);
     }
     $imgs = $imgs->paginate($perpage);
     if (count($imgs) > 0) {
         $res['imgs'] = $imgs->toJson();
     }
     return response()->json($res);
 }
Esempio n. 9
0
 public function getIndex(Request $request)
 {
     User::createTable();
     // User::createAdmin('*****@*****.**','admin');
     Img::createTable();
     Mylog::createTable();
     Email::createTable();
     Banner::createTable();
     Activity::createTable();
     Form::createTable();
     Field::createTable();
     FieldChildren::createTable();
     Result::createTable();
     ResultRow::createTable();
     Charge::createTable();
 }
 public function postUpload(Request $request)
 {
     $res = ['response' => 'YES', 'status' => 0];
     $type = 'FroalaEditor';
     if ($request->hasFile('file')) {
         $imgInfos = ImageTools::resize($request, $type);
         if (!empty($imgInfos)) {
             $img = Img::create(['img_cuid' => $request->user()->user_id, 'img_block' => $type, 'img_filename' => $imgInfos['imgName'], 'img_filetype' => $imgInfos['imgType'], 'img_uri' => $imgInfos['imgUri'], 'img_hd' => $imgInfos['hd'], 'img_big' => $imgInfos['big'], 'img_small' => $imgInfos['small'], 'img_tiny' => $imgInfos['tiny'], 'img_square' => $imgInfos['square'], 'img_active' => 0]);
             $res['status'] = 1;
             $res['id'] = $img->img_id;
             $res['link'] = $img->img_small;
             $res['msgSuccess'] = '成功';
         } else {
             $res = '没有上传成功哦,稍后再试吧';
         }
     } else {
         $res['msgError'] = '没有文件';
     }
     return response()->json($res);
 }
Esempio n. 11
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     // $schedule->command('inspire')
     //          ->hourly();
     // $schedule->call(function (){
     //     Task::bannerImgClear();
     //     Task::activityImgClear();
     // })->everyMinute()->before(function () {
     // });
     $schedule->call(function () {
         $clearTimeDiff = 1;
         $clearNum = 5;
         $imgs = Img::orderBy('created_at', 'ASC')->where('img_block', 'open-form')->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-{$clearTimeDiff} minute", strtotime(date("Y-m-d H:i:s")))))->take($clearNum)->get();
         foreach ($imgs as $img) {
             if (!$img->FieldChildren) {
                 if (file_exists(public_path() . $img->img_uri)) {
                     unlink(public_path() . $img->img_uri);
                 }
                 if (file_exists(public_path() . $img->img_hd)) {
                     unlink(public_path() . $img->img_hd);
                 }
                 if (file_exists(public_path() . $img->img_big)) {
                     unlink(public_path() . $img->img_big);
                 }
                 if (file_exists(public_path() . $img->img_small)) {
                     unlink(public_path() . $img->img_small);
                 }
                 if (file_exists(public_path() . $img->img_tiny)) {
                     unlink(public_path() . $img->img_tiny);
                 }
                 if (file_exists(public_path() . $img->img_square)) {
                     unlink(public_path() . $img->img_square);
                 }
                 if (!file_exists(public_path() . $img->img_hd) && !file_exists(public_path() . $img->img_big) && !file_exists(public_path() . $img->img_small) && !file_exists(public_path() . $img->img_tiny)) {
                     $img->forceDelete();
                 }
             }
         }
     });
 }
Esempio n. 12
0
 public function postDel(Request $request, $img_id)
 {
     $res = ['response' => 'YES', 'status' => 0];
     $img = Img::findOrFail($img_id);
     if ($img->img_active == 0) {
         if (file_exists(public_path() . $img->img_hd)) {
             unlink(public_path() . $img->img_hd);
         }
         if (file_exists(public_path() . $img->img_big)) {
             unlink(public_path() . $img->img_big);
         }
         if (file_exists(public_path() . $img->img_small)) {
             unlink(public_path() . $img->img_small);
         }
         if (file_exists(public_path() . $img->img_tiny)) {
             unlink(public_path() . $img->img_tiny);
         }
         if (file_exists(public_path() . $img->img_square)) {
             unlink(public_path() . $img->img_square);
         }
         if (file_exists(public_path() . $img->img_uri)) {
             unlink(public_path() . $img->img_uri);
         }
         $p = !file_exists(public_path() . $img->img_hd) && !file_exists(public_path() . $img->img_big) && !file_exists(public_path() . $img->img_small) && !file_exists(public_path() . $img->img_tiny) && !file_exists(public_path() . $img->img_uri);
         if ($p) {
             $img->forceDelete();
             if (!Img::find($img_id)) {
                 $res['status'] = 1;
             } else {
                 $res['msgError'] = MSG_FA;
             }
         } else {
             $res['msgError'] = '出错了...';
         }
     } else {
         $res['msgError'] = '该图片正在被使用,请先删除相关关联,再试';
     }
     return response()->json($res);
 }
Esempio n. 13
0
 public function uploadstore(Request $request)
 {
     if ($request->hasFile('file')) {
         if ($request->file('file')->isValid()) {
             $OriginalName = $request->file('file')->getClientOriginalName();
             $file_pre = sha1(time() . $OriginalName);
             //取得当前时间戳
             $file_suffix = substr(strchr($request->file('file')->getMimeType(), "/"), 1);
             //取得文件后缀
             $destinationPath = 'uploads';
             //上传路径
             $fileName = $file_pre . '.' . $file_suffix;
             //上传文件名
             $thumbnail_name = 'thumbnail_' . $file_pre . '.' . $file_suffix;
             Image::make($request->file('file'))->fit(160)->save('uploads/thumbnails/' . $thumbnail_name);
             $request->file('file')->move($destinationPath, $fileName);
             $img = new Img();
             $img->thumbnail = $thumbnail_name;
             $img->name = $fileName;
             $img->album_id = $request->album;
             $img->save();
             Session()->flash('img', $fileName);
             return $fileName;
         } else {
             return "上传文件无效!";
         }
     } else {
         return "文件上传失败!";
     }
 }
Esempio n. 14
0
		'selector'=>'.froalaEditor',
		'options'=>[
			'height'=>'300',
			],
		])

	<script type="text/javascript">
		<?php 
$img = '';
$imgId = 0;
$imgUrl = '';
if ($product) {
    $img = $product->Img()->first();
}
if (old('product_img_id')) {
    $img = \App\Img::find(old('product_img_id'));
}
if ($img) {
    $imgId = $img->img_id;
    $imgUrl = $img->img_small;
}
?>

		$('#uploadZone').myDropzone({
			uploadUrl: '/img/upload/public',
			uploadField: 'product_img_id',
			rowNumber:1,
			limited:1,
		});

		$('#uploadZone').myDropzoneInsertImg({
Esempio n. 15
0
			rowNumber:1,
			limited:1,
		});

		$('#uploadZone1').myDropzoneInsertImg({
			uploadField:  'activity_img_icon',
			imgId: '{{$imgId}}',
			imgUrl: '{{$imgUrl}}',
		});

		<?php 
$img = '';
$imgId = 0;
$imgUrl = '';
if (old('activity_img_bg')) {
    $img = \App\Img::find(old('activity_img_bg'));
}
if ($img) {
    $imgId = $img->img_id;
    $imgUrl = $img->img_small;
}
?>
		
		$('#uploadZone2').myDropzone({
			uploadUrl: '/img/upload/public',
			uploadField: 'activity_img_bg',
			rowNumber:1,
			limited:1,
		});

		$('#uploadZone2').myDropzoneInsertImg({
Esempio n. 16
0

@section('js_extra')
	@include('layouts.plugin.dropzoneUpload.multiple-js')
	@include('manage.img.imgbox-js')

	<script type="text/javascript">
		<?php 
$img = '';
$imgId = 0;
$imgUrl = '';
if ($banner) {
    $img = $banner->Img_main()->first();
}
if (old('banner_img_main')) {
    $img = \App\Img::find(old('banner_img_main'));
}
if ($img) {
    $imgId = $img->img_id;
    $imgUrl = $img->img_small;
}
?>

		$('#uploadZone').myDropzone({
			uploadUrl: '/img/upload/public',
			uploadField:  'banner_img_main',
			uploadTips: '点击或拖拽上传',
			rowNumber:1,
			limited:1,
		});
Esempio n. 17
0
	$('#uploadZone').myDropzone({
		uploadUrl: '/img/upload/public',
		uploadField: 'form_img_thumbnail',
		rowNumber:1,
		limited:1,
	});

	<?php 
$img = '';
$imgId = 0;
$imgUrl = '';
if ($form) {
    $img = $form->Img_thumbnail()->first();
}
if (old('form_img_thumbnail')) {
    $img = \App\Img::find(old('form_img_thumbnail'));
}
if ($img) {
    $imgId = $img->img_id;
    $imgUrl = $img->img_small;
}
?>

	$('#uploadZone').myDropzoneInsertImg({
		uploadField:  'form_img_thumbnail',
		imgId: '{{$imgId}}',
		imgUrl: '{{$imgUrl}}',
	});

	$(function(){
		
Esempio n. 18
0
 public function postUpdate(FormPRequest $request, $form_code)
 {
     $form = Form::where('form_code', '=', $form_code)->where('form_type', 'template')->firstOrFail();
     $inputs = $request->only('form_title', 'form_summary', 'form_desc', 'form_sort', 'form_active');
     if ($inputs['form_active'] == '') {
         $inputs['form_active'] = 0;
     }
     $inputs['form_img_thumbnail'] = $request->input('form_img_thumbnail', 0);
     // img处理
     $img = $form->Img_thumbnail()->first();
     if ($img && $img->img_id != $inputs['form_img_thumbnail']) {
         $img->decouple();
     }
     $form = $form->update($inputs);
     if ($inputs['form_img_thumbnail']) {
         Img::find($inputs['form_img_thumbnail'])->relation();
     }
     if ($form) {
         $res = redirect('/manage/template/list')->with('msgSuccess', MSG_SU);
     } else {
         $res = redirect()->back()->with('msgError', MSG_FA);
     }
     return $res;
 }