本文整理汇总了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;
}
示例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
}