当前位置: 首页>>代码示例>>PHP>>正文


PHP File::delete方法代码示例

本文整理汇总了PHP中File::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP File::delete方法的具体用法?PHP File::delete怎么用?PHP File::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * Delete a file (remove it from the disk)
  *
  * @param   string  $fileName  The full path to the file
  *
  * @return  boolean  True on success
  */
 public function delete($fileName)
 {
     $ret = $this->fileAdapter->delete($fileName);
     if (!$ret && is_object($this->abstractionAdapter)) {
         return $this->abstractionAdapter->delete($fileName);
     }
     return $ret;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:15,代码来源:Hybrid.php

示例2: deleteFile

 /**
  * Delete downloadable file from path and DB
  *
  * @param $id
  * @return mixed
  */
 public function deleteFile($id)
 {
     $file = Download::find($id);
     File::delete($file->filename);
     $file->delete();
     return redirect()->back()->with('flash_message', $file->filename . ' deleted');
 }
开发者ID:heidilux,项目名称:Laravel-Company-Directory,代码行数:13,代码来源:DownloadController.php

示例3: boot

 public static function boot()
 {
     parent::boot();
     static::deleting(function ($medium) {
         \File::delete($medium->path);
     });
 }
开发者ID:wislem,项目名称:scaffenger,代码行数:7,代码来源:Media.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $familia = Familia::findOrFail($id);
     $validator = Familia::validator(Input::all());
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $datos = Input::all();
     if (Input::file('foto')) {
         $file = Input::file('foto');
         $destinationPath = 'uploads/images/';
         $filename = Str::random(20) . '.' . $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $extension = $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename);
         if ($familia->foto != 'fam.jpg') {
             File::delete($destinationPath . $familia->foto);
         }
         $datos['foto'] = $filename;
     } else {
         unset($datos['foto']);
     }
     $familia->update($datos);
     Session::flash('message', 'Actualizado Correctamente');
     Session::flash('class', 'success');
     return Redirect::to('/dashboard/familia');
 }
开发者ID:bjohnmer,项目名称:sf,代码行数:33,代码来源:FamiliasController.php

示例5: saveAsThumbnail

 public function saveAsThumbnail($folderPath, $fileName_withExtension, $targetHeight, $targetWidth)
 {
     /* load up the image */
     $image = Yii::app()->image->load($this->filePath);
     /* determine the original image property landscape or protrait */
     $imageWidth = $image->width;
     $imageHeight = $image->height;
     $isImageLandscape = $imageWidth > $imageHeight;
     $isImageProtrait = $imageHeight > $imageWidth;
     $isImageSquare = $imageHeight == $imageWidth;
     /* determine the target image property */
     $isTargetImageLandscape = $targetWidth > $targetHeight;
     $isTargetImageProtrait = $targetHeight > $targetWidth;
     $isTargetImageSquare = $targetHeight == $targetWidth;
     $finalImagePath = $folderPath . '/' . $fileName_withExtension;
     if (file_exists($finalImagePath)) {
         $file = new File($finalImagePath);
         $file->delete();
     }
     $image->resize($targetWidth, $targetHeight, Image::WIDTH);
     $resizeFactor = $targetWidth / $imageWidth;
     $resizedImageHeight = ceil($imageHeight * $resizeFactor);
     if ($resizedImageHeight < $targetHeight) {
         $image->crop($targetHeight, $targetWidth);
         $image->resize($targetWidth, $targetHeight, Image::HEIGHT);
     } else {
         if ($resizedImageHeight > $targetHeight) {
             $image->crop($targetHeight, $targetWidth);
         }
     }
     $image->save($finalImagePath);
     return $finalImagePath;
     //$image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20);
     //$image->save(); // or $image->save('images/small.jpg');
 }
开发者ID:kittolau,项目名称:gcm,代码行数:35,代码来源:ThumbnailImageGenerator.php

示例6: postDelete

 /**
  * Remove the specified company from storage.
  *
  * @param $company
  * @return Response
  */
 public function postDelete($model)
 {
     // Declare the rules for the form validation
     $rules = array('id' => 'required|integer');
     // Validate the inputs
     $validator = Validator::make(Input::All(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $id = $model->id;
         $model->delete();
         $file_path = public_path() . '/uploads/' . $model->filename;
         $file_ok = true;
         if (File::exists($file_path)) {
             $file_ok = false;
             File::delete($file_path);
             if (!File::exists($file_path)) {
                 $file_ok = true;
             }
         }
         // Was the blog post deleted?
         $Model = $this->modelName;
         $model = $Model::find($id);
         if (empty($model) && $file_ok) {
             // Redirect to the blog posts management page
             return Response::json(['success' => 'success', 'reload' => true]);
         }
     }
     // There was a problem deleting the blog post
     return Response::json(['error' => 'error', 'reload' => false]);
 }
开发者ID:strikles,项目名称:php,代码行数:36,代码来源:PicturesController.php

示例7: update

 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required', 'lastname' => 'required', 'password' => 'required|min:6', 'email' => 'required|email']);
     $user = User::find($id)->first();
     if ($request->file('edit-user-photo')) {
         $this->validate($request, ['edit-user-photo' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $userFile = $user->avatar_path . $user->avatar;
         if (\File::isFile($userFile)) {
             \File::delete($userFile);
         }
         $file = $request->file('edit-user-photo');
         $avatar_path = $this->_user_photo_path;
         $avatar = $file->getClientOriginalName();
         $file->move($avatar_path, $avatar);
         $user->avatar = $avatar;
         $user->avatar_path = $avatar_path;
     }
     $user->name = $request->get('name');
     $user->lastname = $request->get('lastname');
     $user->email = $request->get('email');
     $user->password = bcrypt($request->get('password'));
     $user->save();
     flash()->success('', 'Redaguotas!');
     return redirect()->back();
 }
开发者ID:leloulight,项目名称:RealMadrid,代码行数:25,代码来源:UserController.php

示例8: update

 public function update($id)
 {
     if (Auth::id() != $id) {
         return Redirect::to('http://google.com');
     }
     $user = Auth::User();
     $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->passes()) {
         $img_ava = $user->avatar_img;
         $password = Input::get('password');
         if (Input::hasFile('avatar_img')) {
             if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) {
                 File::delete(Config::get('user.upload_user_ava_directory') . $img_ava);
             }
             if (!is_dir(Config::get('user.upload_user_ava_directory'))) {
                 File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true);
             }
             $img = Image::make(Input::file('avatar_img'));
             $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension();
             if ($img->width() < $img->height()) {
                 $img->resize(100, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             } else {
                 $img->resize(null, 100, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             }
         }
         $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
         return Redirect::back()->with('success_msg', Lang::get('messages.successupdate'));
     } else {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }
开发者ID:rezadaulay,项目名称:bankupu,代码行数:35,代码来源:SessionController.php

示例9: setImageAttribute

 /**
  * Upload the image while creating/updating records
  * @param File Object $file
  */
 public function setImageAttribute($file)
 {
     // Only if a file is selected
     if ($file) {
         File::exists(public_path() . '/uploads/') || File::makeDirectory(public_path() . '/uploads/');
         File::exists(public_path() . '/' . $this->images_path) || File::makeDirectory(public_path() . '/' . $this->images_path);
         File::exists(public_path() . '/' . $this->thumbs_path) || File::makeDirectory(public_path() . '/' . $this->thumbs_path);
         $file_name = $file->getClientOriginalName();
         $file_ext = File::extension($file_name);
         $only_fname = str_replace('.' . $file_ext, '', $file_name);
         $file_name = $only_fname . '_' . str_random(8) . '.' . $file_ext;
         $image = Image::make($file->getRealPath());
         if (isset($this->attributes['folder'])) {
             // $this->attributes['folder'] = Str::slug($this->attributes['folder'], '_');
             $this->images_path = $this->attributes['folder'] . '/';
             $this->thumbs_path = $this->images_path . '/thumbs/';
             File::exists(public_path() . '/' . $this->images_path) || File::makeDirectory(public_path() . '/' . $this->images_path);
             File::exists(public_path() . '/' . $this->thumbs_path) || File::makeDirectory(public_path() . '/' . $this->thumbs_path);
         }
         if (isset($this->attributes['image'])) {
             // Delete old image
             $old_image = $this->getImageAttribute();
             File::exists($old_image) && File::delete($old_image);
         }
         if (isset($this->attributes['thumbnail'])) {
             // Delete old thumbnail
             $old_thumb = $this->getThumbnailAttribute();
             File::exists($old_thumb) && File::delete($old_thumb);
         }
         $image->save(public_path($this->images_path . $file_name))->fit(150, 150)->save(public_path($this->thumbs_path . $file_name));
         $this->attributes['image'] = "{$this->attributes['folder']}/{$file_name}";
         $this->attributes['thumbnail'] = "{$this->attributes['folder']}/thumbs/{$file_name}";
         unset($this->attributes['folder']);
     }
 }
开发者ID:doptor,项目名称:doptor,代码行数:39,代码来源:MediaEntry.php

示例10: boot

 public static function boot()
 {
     parent::boot();
     News::deleting(function ($newsItem) {
         File::delete($newsItem->image);
     });
 }
开发者ID:TemRhythm,项目名称:priola-website,代码行数:7,代码来源:News.php

示例11: agregar

 public function agregar()
 {
     $userid = Auth::user()->id;
     $curso = new Curso();
     $curso->nombre = Input::get('nombre');
     $curso->descripcion = Input::get('descripcion');
     //$file = Input::file('image');
     $curso->activo = Input::get('activo');
     $curso->tipo = Input::get('tipo');
     $curso->basefile = "";
     $curso->id_user = 1;
     $curso->save();
     $the_id = $curso->id;
     $curso = Curso::find($the_id);
     $file = Input::file('logo');
     $destinationPath = 'temp/';
     $filename = $userid . "" . $file->getClientOriginalName();
     Input::file('logo')->move($destinationPath, $filename);
     $file = ParseFile::createFromFile($destinationPath . "/" . $filename, $filename);
     $file->save();
     $url = $file->getURL();
     $curso->img = "" . $url;
     $jobApplication = new ParseObject("cursos");
     $jobApplication->set("myid", $the_id);
     $jobApplication->set("img", $file);
     $jobApplication->save();
     $curso->save();
     File::delete($destinationPath . "/" . $filename);
 }
开发者ID:pblquijano,项目名称:Scauti,代码行数:29,代码来源:AdminController.php

示例12: updateInactiveModules

 /**
  * Update the inactive modules
  * @param mixed
  * @return mixed
  */
 public function updateInactiveModules($varValue)
 {
     $arrModules = deserialize($varValue);
     if (!is_array($arrModules)) {
         $arrModules = array();
     }
     foreach (scan(TL_ROOT . '/system/modules') as $strModule) {
         if (strncmp($strModule, '.', 1) === 0) {
             continue;
         }
         // Add the .skip file to disable the module
         if (in_array($strModule, $arrModules)) {
             if (!file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->write('As long as this file exists, the module will be ignored.');
                 $objFile->close();
             }
         } else {
             if (file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->delete();
             }
         }
     }
     return $varValue;
 }
开发者ID:rikaix,项目名称:core,代码行数:31,代码来源:tl_settings.php

示例13: destroy

 public function destroy($id)
 {
     $image = Image::find($id);
     $image->delete();
     File::delete($image->image);
     return Redirect::back()->withInput()->withErrors('Image #' . $id . ' was deleted.');
 }
开发者ID:slopedoo,项目名称:laravel,代码行数:7,代码来源:ImagesController.php

示例14: cropCoverPhoto

 public function cropCoverPhoto($Croppath, $upload_id)
 {
     $uploader = new Utils_Uploader(array('jpeg', 'jpg', 'png'));
     $uploads = self::find($upload_id);
     $oldpath = $uploads->path;
     $oldname = $uploads->name;
     $uploadTypeModel = Model_Upload_Type::find($uploads->type_id);
     $typeName = $uploadTypeModel->types;
     if (file_exists($oldpath . $oldname)) {
         File::delete($oldpath . $oldname);
     }
     $img = $Croppath;
     $img = str_replace('data:image/png;base64,', '', $img);
     $img = str_replace(' ', '+', $img);
     $data = base64_decode($img);
     $file = $oldpath . "crop_image_" . $upload_id . ".png";
     $original = $oldpath . $oldname;
     //$thumbnail = $path . 'min_' . $newFile;
     $success = file_put_contents($file, $data);
     //Image::load($file)->preset('coverimage')->save($thumbnail); //360 width
     Image::load($file)->preset($typeName)->save($original);
     //1260 width
     File::delete($file);
     return $oldname;
 }
开发者ID:sajans,项目名称:cms,代码行数:25,代码来源:upload.php

示例15: boot

 public static function boot()
 {
     parent::boot();
     Event::deleting(function ($event) {
         File::delete($event->image);
     });
 }
开发者ID:TemRhythm,项目名称:priola-website,代码行数:7,代码来源:MassMediaNewsImage.php


注:本文中的File::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。