當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::removespace方法代碼示例

本文整理匯總了PHP中app\File::removespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::removespace方法的具體用法?PHP File::removespace怎麽用?PHP File::removespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\File的用法示例。


在下文中一共展示了File::removespace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveAvatar

 /**
  * upload avatar
  * @param $file
  * @param $user_id
  * @return mixed
  */
 public static function saveAvatar($file, $user_id)
 {
     $now_date = str_replace('/', '_', date('d/m/Y'));
     $filename = $file->getClientOriginalName();
     $filename = File::removesign($filename);
     $filename = File::removespace($filename);
     $newfilename = $now_date . '_' . rand(1, 99999) . '_' . $filename;
     Storage::put('avatar/' . $newfilename, file_get_contents($file->getRealPath()));
     //$upload_success = $file->move($destinationPath, $newfilename);
     $path = storage_path('uploads/avatar/' . $newfilename);
     $img = Image::make($path);
     // resize image instance
     $img->resize(320, 240);
     $savefile = new File(['name' => $newfilename, 'mine' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'nguoiupload_id' => $user_id]);
     $savefile->save();
     return $savefile->id;
 }
開發者ID:thaigialai1987,項目名稱:qlcv,代碼行數:23,代碼來源:File.php

示例2: send

 public function send()
 {
     // get input
     $to = \Input::get('nguoinhan');
     $tos = preg_split("/[\\s;]+/", $to);
     $cc = \Input::get('nguoinhankhac');
     $ccs = preg_split("/[\\s;]+/", $cc);
     $subject = \Input::get('tieude');
     $message = \Input::get('noidung');
     //echo '<pre>';
     //print_r($ccs);
     //$toEmails = array('one@email.com', 'two@email.com', 'three@email.com', 'four@email.com');
     // has file
     if (\Input::hasFile('attachment')) {
         $now_date = str_replace('/', '_', date('d/m/Y'));
         $files = \Input::file('attachment');
         $newnamefiles = array();
         foreach ($files as $file) {
             $destinationPath = 'uploads';
             $filename = $file->getClientOriginalName();
             $filename = File::removesign($filename);
             $filename = File::removespace($filename);
             $newfilename = $now_date . '_' . rand(1, 99999) . '_' . $filename;
             $upload_success = $file->move($destinationPath, $newfilename);
             array_push($newnamefiles, $newfilename);
         }
         $path = array();
         foreach ($newnamefiles as $value) {
             $filepath = 'uploads/' . $value;
             array_push($path, $filepath);
         }
         // không cc
         if ($ccs[0] == '') {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use($path, $tos, $ccs, $subject) {
                 $message->from('taynguyen.net@gmail.com', 'Lê Thanh Thái');
                 $message->to($tos)->subject($subject);
                 $size = count($path);
                 for ($i = 0; $i < $size; $i++) {
                     $message->attach($path[$i]);
                 }
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         } else {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use($path, $tos, $ccs, $subject) {
                 $message->from('taynguyen.net@gmail.com', 'Lê Thanh Thái');
                 $message->to($tos)->cc($ccs)->subject($subject);
                 $size = count($path);
                 for ($i = 0; $i < $size; $i++) {
                     $message->attach($path[$i]);
                 }
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         }
     } else {
         if ($ccs[0] == '') {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use($tos, $ccs, $subject) {
                 $message->from('taynguyen.net@gmail.com', 'Lê Thanh Thái');
                 $message->to($tos)->subject($subject);
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         } else {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use($tos, $ccs, $subject) {
                 $message->from('taynguyen.net@gmail.com', 'Lê Thanh Thái');
                 $message->to($tos)->cc($ccs)->subject($subject);
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         }
     }
     //end send
 }
開發者ID:thaigialai1987,項目名稱:qlcv,代碼行數:70,代碼來源:MymailController.php


注:本文中的app\File::removespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。