本文整理匯總了PHP中Illuminate\Support\Facades\File::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::delete方法的具體用法?PHP File::delete怎麽用?PHP File::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: start
public function start(Request $request)
{
$this->validate($request, ['entity' => 'required|integer|between:1,6', 'file' => 'required']);
$file = $request->file('file');
$path = $file->move('uploads', str_random(16) . time() . '.csv');
$entity = $request->input('entity');
switch ($entity) {
case 1:
$this->importStudents($path);
break;
case 2:
$this->importProfessors($path);
break;
case 3:
$this->importModules($path);
break;
case 4:
$this->importCourses($path);
break;
case 5:
$this->importGroups($path);
break;
case 6:
$this->importEvents($path);
break;
}
File::delete($file);
return redirect()->back();
}
示例2: boot
public static function boot()
{
parent::boot();
ProductLine::deleting(function ($productLine) {
File::delete($productLine->image);
});
}
示例3: boot
public static function boot()
{
parent::boot();
ProductColor::deleting(function ($productColor) {
File::delete($productColor->image);
});
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
if (Input::file('file')->isValid()) {
$filePath = date('Ymd_His') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) {
//example of delete exist file
$announceList = Announce::all();
if (sizeof($announceList) != 0) {
$lastAnnounce = $announceList[sizeof($announceList) - 1];
$filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
// $oldAnnounce = Announce::findOrNew($lastAnnounce->id);
$lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first();
// dd($lastAnnounce);die;
if ($lastAnnounce != null) {
Announce::destroy($lastAnnounce->id);
}
}
$announce = new Announce();
$announce->file_path = $filePath;
$announce->year = $request->get('year');
$announce->save();
return redirect('/announces');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
示例5: boot
public static function boot()
{
parent::boot();
CourseGalleryItem::deleting(function ($courseGalleryItem) {
File::delete($courseGalleryItem->image);
});
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
$riskManagements = RiskManagement::where('year', '=', $request->get('year'))->where('period', '=', $request->get('period'))->get();
if (sizeof($riskManagements) > 0) {
foreach ($riskManagements as $riskManagement) {
$filename = base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period') . '/' . $riskManagement->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
RiskManagement::destroy($riskManagement->id);
}
}
if (Input::file('file')->isValid()) {
$filePath = date('Ymd_His') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period'), $filePath)) {
//example of delete exist file
$riskManagement = new RiskManagement();
$riskManagement->file_path = $filePath;
$riskManagement->year = $request->get('year');
$riskManagement->period = $request->get('period');
$riskManagement->save();
return redirect('/admin/management');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
示例7: putEdit
public function putEdit(Request $request)
{
if (!ACL::hasPermission('awards', 'edit')) {
return redirect(route('awards'))->withErrors(['Você não pode editar os prêmios.']);
}
$this->validate($request, ['title' => 'required|max:45', 'warning' => 'required', 'image' => 'image|mimes:jpeg,bmp,gif,png'], ['title.required' => 'Informe o título do prêmio', 'title.max' => 'O título do prêmio não pode passar de :max caracteres', 'warning.required' => 'Informe o aviso sobre o prêmio', 'image.image' => 'Envie um formato de imagem válida', 'image.mimes' => 'Formato suportado: .png com fundo transparente']);
$award = Awards::find($request->awardsId);
$award->title = $request->title;
$award->warning = $request->warning;
if ($request->image) {
//DELETE OLD IMAGE
if ($request->currentImage != "") {
if (File::exists($this->folder . $request->currentImage)) {
File::delete($this->folder . $request->currentImage);
}
}
$extension = $request->image->getClientOriginalExtension();
$nameImage = Carbon::now()->format('YmdHis') . "." . $extension;
Image::make($request->file('image'))->resize($this->imageWidth, $this->imageHeight)->save($this->folder . $nameImage);
$award->image = $nameImage;
}
$award->save();
$success = "Prêmio editado com sucesso";
return redirect(route('awards'))->with(compact('success'));
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store($image, $type, $primary_id, $current_link)
{
$image_link = array_key_exists($type, Input::all()) ? Input::file($type) != '' ? '/allgifted-images/' . $type . '/' . $primary_id . '.' . $image->getClientOriginalExtension() : $current_link : $current_link;
array_key_exists($type, Input::all()) ? File::exists(public_path($image_link)) ? File::delete(public_path($image_link)) : null : null;
$image ? Image::make($image)->fit(500, 300)->save(public_path($image_link)) : null;
return $image_link;
}
示例9: boot
public static function boot()
{
parent::boot();
RegionWorkshop::deleting(function ($regionWorkshop) {
File::delete($regionWorkshop->image);
});
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if (Input::file()) {
$profile = $this->profile->find($this->user->profile->id);
$old = $profile->avatar;
$path = public_path() . '/images/profiles/' . $old;
if (File::exists($path)) {
File::delete($path);
}
}
$file = $request->file('file');
$filename = str_random(30) . time() . date('dmY') . '.' . $file->getClientOriginalExtension();
$file->move('images/profiles', $filename);
dd();
// save profile pic
if (Input::file()) {
$profile = $this->profile->find($this->user->profile->id);
$old = $profile->avatar;
$path = public_path() . '/images/profiles/' . $old;
if (File::exists($path)) {
File::delete($path);
}
$string = str_random(30);
$image = Input::file('image');
$filename = $string . time() . date('dmY') . '.' . $image->getClientOriginalExtension();
$path = public_path('/images/profiles/' . $filename);
Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
$constraint->aspectRatio();
})->save($path, 60);
$profile->avatar = $filename;
$profile->save();
return redirect()->route('profiles.index');
}
}
示例11: boot
public static function boot()
{
parent::boot();
MainPageSlide::deleting(function ($mainPageSlide) {
File::delete($mainPageSlide->image);
});
}
示例12: fire
/**
* Execute the console command.
*/
public function fire()
{
$this->line('');
$this->info('Routes file: app/routes.php');
$message = 'This will rebuild routes.php with all of the packages that' . ' subscribe to the `toolbox.routes` event.';
$this->comment($message);
$this->line('');
if ($this->confirm('Proceed with the rebuild? [Yes|no]')) {
$this->line('');
$this->info('Backing up routes.php ...');
// Remove the last backup if it exists
if (File::exists('app/routes.bak.php')) {
File::delete('app/routes.bak.php');
}
// Back up the existing file
if (File::exists('app/routes.php')) {
File::move('app/routes.php', 'app/routes.bak.php');
}
// Generate new routes
$this->info('Generating routes...');
$routes = Event::fire('toolbox.routes');
// Save new file
$this->info('Saving new routes.php...');
if ($routes && !empty($routes)) {
$routes = $this->getHeader() . implode("\n", $routes);
File::put('app/routes.php', $routes);
$this->info('Process completed!');
} else {
$this->error('Nothing to save!');
}
// Done!
$this->line('');
}
}
示例13: destroy
public function destroy($id)
{
$this->wish = Wish::find($id);
File::delete(public_path('img/wishes/') . $this->wish->picture);
$this->wish->delete();
return $this->getWishes();
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param TemplateRequest $request
* @return Response
*/
public function store(TemplateRequest $request)
{
ini_set('max_execution_time', 0);
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
$file_path = storage_path('tmp/');
$orginal_name = $request->file('file')->getClientOriginalName();
if ($request->file('file')->move($file_path, $orginal_name)) {
Zipper::make($file_path . $orginal_name)->extractTo(storage_path('tmp'));
$template = (require_once storage_path('tmp/Template.php'));
$assets = File::move(storage_path('tmp/assets/' . $template['folder']), public_path('assets/' . $template['folder']));
$template_file = File::move(storage_path('tmp/' . $template['folder']), base_path('resources/views/' . $template['folder']));
if (!$assets || !$template_file) {
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::error('Tema Dosyası Yüklendi ama Dizinler Tasinamadi! Tüm İşlemleriniz İptal Edildi.');
return redirect()->route('admin.template.index');
}
$message = $this->template->create($template) ? ['success', 'Başarıyla Kaydedildi'] : ['error', 'Bir Hata Meydana Geldi ve Kaydedilemedi'];
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::$message[0]($message[1]);
if ($message[0] == "success") {
Logs::add('process', "Şablon Eklendi\n{$template['name']}");
} else {
Logs::add('errors', "Şablon Eklenemedi!");
}
return redirect()->route('admin.template.index');
}
}
示例15: putEdit
public function putEdit(Request $request)
{
if (!ACL::hasPermission('winners2014', 'edit')) {
return redirect(route('winners2014'))->withErrors(['Você não pode editar os ganhadores de 2014.']);
}
$this->validate($request, ['category' => 'required', 'position' => 'required', 'name' => 'required|max:50', 'city' => 'required|max:45', 'state' => 'required|max:2|min:2', 'quantityVotes' => 'required|numeric', 'image' => 'image|mimes:jpeg,bmp,gif,png'], ['category.required' => 'Escolha a categoria', 'position.required' => 'Escolha a posição', 'name.required' => 'Informe o nome do ganhador', 'name.max' => 'O nome do ganhador não pode passar de :max caracteres', 'city.required' => 'Informe o nome da cidade do ganhador', 'city.max' => 'O nome da cidade não pode passar de :max caracteres', 'state.required' => 'Informe o Estado do ganhador', 'state.max' => 'O UF do Estado deve ter apenas :max caracteres', 'state.min' => 'O UF do Estado deve ter apenas :min caracteres', 'quantityVotes.required' => 'Informe a quantidade de votos', 'quantityVotes.numeric' => 'Somente números são aceitos', 'image.image' => 'Envie um formato de imagem válida', 'image.mimes' => 'Formatos suportados: .jpg, .gif, .bmp e .png']);
$winner = WinnersLastYear::find($request->winnersLastYearId);
$winner->category = $request->category;
$winner->position = $request->position;
$winner->name = $request->name;
$winner->city = $request->city;
$winner->state = $request->state;
$winner->quantityVotes = $request->quantityVotes;
if ($request->photo) {
//DELETE OLD PHOTO
if ($request->currentPhoto != "") {
if (File::exists($this->folder . $request->currentPhoto)) {
File::delete($this->folder . $request->currentPhoto);
}
}
$extension = $request->photo->getClientOriginalExtension();
$namePhoto = Carbon::now()->format('YmdHis') . "." . $extension;
$img = Image::make($request->file('photo'));
if ($request->photoCropAreaW > 0 or $request->photoCropAreaH > 0 or $request->photoPositionX or $request->photoPositionY) {
$img->crop($request->photoCropAreaW, $request->photoCropAreaH, $request->photoPositionX, $request->photoPositionY);
}
$img->resize($this->photoWidth, $this->photoHeight)->save($this->folder . $namePhoto);
$winner->photo = $namePhoto;
}
$winner->save();
$success = "Ganhador editado com sucesso";
return redirect(route('winners2014'))->with(compact('success'));
}