delete() public static method

Delete the file at a given path.
public static delete ( string | array $paths ) : boolean
$paths string | array
return boolean
Example #1
0
 /**
  * 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;
 }
 /**
  * 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');
 }
Example #3
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($medium) {
         \File::delete($medium->path);
     });
 }
Example #4
0
 /**
  * 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');
 }
Example #5
0
 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');
 }
Example #6
0
 /**
  * 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]);
 }
Example #7
0
 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();
 }
Example #8
0
 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();
     }
 }
Example #9
0
 /**
  * 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']);
     }
 }
Example #10
0
 public static function boot()
 {
     parent::boot();
     News::deleting(function ($newsItem) {
         File::delete($newsItem->image);
     });
 }
Example #11
0
 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);
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 public function destroy($id)
 {
     $image = Image::find($id);
     $image->delete();
     File::delete($image->image);
     return Redirect::back()->withInput()->withErrors('Image #' . $id . ' was deleted.');
 }
Example #14
0
 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;
 }
 public static function boot()
 {
     parent::boot();
     Event::deleting(function ($event) {
         File::delete($event->image);
     });
 }
    /**
     * @inheritdoc
     */
    public function handle()
    {
        foreach ($this->dumper_config as $class => $file) {
            if (\File::exists($file)) {
                if (!$this->confirm("file {$file} exists, are you sure to OVERWRITE it? [y|N]")) {
                    continue;
                }
                \File::delete($file);
            }
            $instance = new $class();
            $config = FormDumper::dump($instance);
            $php = var_export($config, true);
            $now = date('Y-m-d H:i:s', time());
            $data = <<<DATA
<?php
/**
 * Created by FormDumper
 * Date: {$now}
 */

 return {$php};
DATA;
            \File::append($file, $data);
        }
    }
Example #17
0
 /**
  * Update all style sheets in the scripts folder
  */
 public function updateStyleSheets()
 {
     $objStyleSheets = $this->Database->execute("SELECT * FROM tl_style_sheet");
     $arrStyleSheets = $objStyleSheets->fetchEach('name');
     // Make sure the dcaconfig.php file is loaded
     @(include TL_ROOT . '/system/config/dcaconfig.php');
     // Delete old style sheets
     foreach (scan(TL_ROOT . '/assets/css', true) as $file) {
         // Skip directories
         if (is_dir(TL_ROOT . '/assets/css/' . $file)) {
             continue;
         }
         // Preserve root files (is this still required now that scripts are in assets/css/scripts?)
         if (is_array($GLOBALS['TL_CONFIG']['rootFiles']) && in_array($file, $GLOBALS['TL_CONFIG']['rootFiles'])) {
             continue;
         }
         // Do not delete the combined files (see #3605)
         if (preg_match('/^[a-f0-9]{12}\\.css$/', $file)) {
             continue;
         }
         $objFile = new \File('assets/css/' . $file);
         // Delete the old style sheet
         if ($objFile->extension == 'css' && !in_array($objFile->filename, $arrStyleSheets)) {
             $objFile->delete();
         }
     }
     $objStyleSheets->reset();
     // Create the new style sheets
     while ($objStyleSheets->next()) {
         $this->writeStyleSheet($objStyleSheets->row());
         $this->log('Generated style sheet "' . $objStyleSheets->name . '.css"', 'StyleSheets updateStyleSheets()', TL_CRON);
     }
 }
 private function accountUpdate($post)
 {
     try {
         $user = Auth::user();
         if ($uploaded = AdminUploadsController::createImageInBase64String('avatar')) {
             if (!empty($user->photo) && File::exists(Config::get('site.uploads_photo_dir') . '/' . $user->photo)) {
                 File::delete(Config::get('site.uploads_photo_dir') . '/' . $user->photo);
             }
             if (!empty($user->photo) && File::exists(Config::get('site.uploads_thumb_dir') . '/' . $user->thumbnail)) {
                 File::delete(Config::get('site.uploads_thumb_dir') . '/' . $user->thumbnail);
             }
             $user->photo = @$uploaded['main'];
             $user->thumbnail = @$uploaded['thumb'];
         }
         $user->name = $post['name'];
         $user->surname = $post['surname'];
         $user->city = $post['city'];
         $user->phone = $post['phone'];
         $user->sex = $post['sex'];
         $bdate = Carbon::createFromFormat('Y-m-d', $post['yyyy'] . '-' . $post['mm'] . '-' . $post['dd'])->format('Y-m-d 00:00:00');
         $user->bdate = $bdate;
         $user->save();
         $user->touch();
     } catch (Exception $e) {
         return FALSE;
     }
     return TRUE;
 }
 /**
  * Update the specified powerful in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $powerful = Powerful::findOrFail($id);
     $rules = array('name' => 'required', 'icon' => 'image');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //upload powerful icon
     if (Input::hasFile('icon')) {
         //delete old icon
         if (File::exists($powerful->icon)) {
             File::delete($powerful->icon);
         }
         //create new icon
         $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension();
         $folder = "public/uploads/powerful";
         Input::file('icon')->move($folder, $name);
         $path = $folder . '/' . $name;
         //update new path
         $data['icon'] = $path;
     } else {
         unset($data['icon']);
     }
     $powerful->update($data);
     return Redirect::route('admin.powerful.index')->with('message', 'Item had updated!');
 }
 public function addProduct()
 {
     $id = \Input::get('id');
     $rules = array('name' => 'required', 'quantity' => 'required|numeric', 'image' => 'image|mimes:jpeg,jpg,png,gif');
     $input = \Input::all();
     $valid = Validator::make($input, $rules);
     if ($valid->fails()) {
         return \Redirect::back()->withErrors($valid);
     } else {
         // If validation success
         $name = \Input::get('name');
         $quantity = \Input::get('quantity');
         $image = \Input::file('image');
         $product = $id ? Products::find($id) : new Products();
         // Creating product elobquent object
         // If image selected
         if ($image) {
             $filename = time() . "-" . $image->getClientOriginalName();
             $path = 'assets/images/' . $filename;
             \Image::make($image->getRealPath())->resize(200, 200)->save($path);
             $existingImage = '/assets/images/' . $product->image;
             if (file_exists($existingImage)) {
                 \File::delete($existingImage);
             }
             $product->image = $filename;
         }
         $product->name = $name;
         $product->quantity = $quantity;
         $product->save();
         return redirect(action('ProductController@product'));
     }
 }
 public function update($id, Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         \DB::statement('SET FOREIGN_KEY_CHECKS = 0');
         $supplier = Supplier::find($id);
         $supplier->fill($request->except('_token'));
         $supplier->parent_id = 0;
         if ($request->password != '') {
             $supplier->password = Hash::make($request->password);
         }
         if (Input::hasFile('profileimage')) {
             $file = Input::file('profileimage');
             $imagename = time() . '.' . $file->getClientOriginalExtension();
             if (\File::exists(public_path('upload/supplierprofile/' . $supplier->image))) {
                 \File::delete(public_path('upload/supplierprofile/' . $supplier->image));
             }
             $path = public_path('upload/supplierprofile/' . $imagename);
             $image = \Image::make($file->getRealPath())->save($path);
             $th_path = public_path('upload/supplierprofile/thumb/' . $imagename);
             $image = \Image::make($file->getRealPath())->resize(128, 128)->save($th_path);
             $supplier->image = $imagename;
         }
         $supplier->save();
         \DB::statement('SET FOREIGN_KEY_CHECKS = 1');
         return Redirect::route('supplier_master_list')->with('succ_msg', 'Supplier has been created successfully!');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['opening' => 'required', 'dimensions' => 'required', 'address' => 'required', 'capacity' => 'required']);
     $santiago = Santiago::find($id);
     if ($request->file('edit-santiago-photo')) {
         $this->validate($request, ['edit-santiago-photo' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $santiagoFile = $santiago->photo_path . $santiago->photo_name;
         if (\File::isFile($santiagoFile)) {
             \File::delete($santiagoFile);
         }
         $file = $request->file('edit-santiago-photo');
         $santiago_photo_path = $this->_santiago_photo_path;
         $santiago_photo_name = $file->getClientOriginalName();
         $file->move($santiago_photo_path, $santiago_photo_name);
         $santiago->photo_name = $santiago_photo_name;
         $santiago->photo_path = $santiago_photo_path;
     }
     $santiago->opening = $request->get('opening');
     $santiago->dimensions = $request->get('dimensions');
     $santiago->address = $request->get('address');
     $santiago->capacity = $request->get('capacity');
     $santiago->save();
     flash()->success('', 'Santiago redaguotas!');
     return Redirect::to('/dashboard/santiago/');
 }
 /**
  * Delete all values from the cache
  *
  * @param boolean $check Optional - only delete expired cache items
  * @return boolean True if the cache was succesfully cleared, false otherwise
  * @access public
  */
 function clear($check)
 {
     if (!$this->__init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check) {
         $now = time();
         $threshold = $now - $this->settings['duration'];
     }
     while (($entry = $dir->read()) !== false) {
         if ($this->__setKey($entry) === false) {
             continue;
         }
         if ($check) {
             $mtime = $this->__File->lastChange();
             if ($mtime === false || $mtime > $threshold) {
                 continue;
             }
             $expires = $this->__File->read(11);
             $this->__File->close();
             if ($expires > $now) {
                 continue;
             }
         }
         $this->__File->delete();
     }
     $dir->close();
     return true;
 }
 /**
  * Execute the job.
  * @return void
  */
 public function handle()
 {
     $s3 = \App::make('aws');
     $s3->createClient('s3')->putObject(['Bucket' => 'transcoderinput435983', 'Key' => $this->key_input, 'SourceFile' => storage_path() . '/app/' . $this->key_input]);
     $s3->createClient('ElasticTranscoder')->createJob(['PipelineId' => env('PIPLINE_ID'), 'Input' => ['Key' => $this->key_input, 'FrameRate' => 'auto', 'Resolution' => 'auto', 'AspectRatio' => 'auto', 'Interlaced' => 'auto', 'Container' => 'auto'], 'Output' => ['Key' => $this->key_output, 'ThumbnailPattern' => $this->time . '_thumb{count}', 'Rotate' => 'auto', 'PresetId' => '1452215960232-me3asn']]);
     \File::delete(storage_path() . '/app/' . $this->key_input);
 }
 public function postProfil()
 {
     $validate = Validator::make(Input::all(), ['adsoyad' => 'required', 'email' => 'required|email|unique:users,email,' . Auth::user()->id . '', 'profil' => 'mimes:jpg,png,gif,jpeg']);
     $messages = $validate->messages();
     if ($validate->fails()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Doğrulama Hatası', 'text' => '' . $messages->first() . '', 'type' => 'error'));
     }
     $user = User::findOrFail(Auth::user()->id);
     $user->namesurname = Input::get('adsoyad');
     if (Input::has('password')) {
         $user->password = Hash::make(Input::get('password'));
         $user->save();
     }
     $user->email = Input::get('email');
     if (Input::hasFile('profil')) {
         if (Auth::user()->profil != '') {
             File::delete('Backend/avatar/' . Auth::user()->profil . '');
         }
         $profil = Input::file('profil');
         $dosyaadi = $profil->getClientOriginalName();
         $uzanti = $profil->getClientOriginalExtension();
         $isim = Str::slug($dosyaadi) . Str::slug(str_random(5)) . '.' . $uzanti;
         $dosya = $profil->move('Backend/avatar/', $isim);
         $image = Image::open('Backend/avatar/' . $isim)->resize(80, 80)->save();
         $user->profil = $isim;
         $user->save();
     }
     $user->save();
     if ($user->save()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellendi', 'text' => 'Kullanıcı Başarı İle Güncellendi', 'type' => 'success'));
     } else {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellenemedi', 'text' => 'Kullanıcı Güncellenirken Sorun İle Karşılaşıldı', 'type' => 'error'));
     }
 }
 public function testDeletingFileMarksBackedPagesAsBroken()
 {
     // Test entry
     $file = new File();
     $file->Filename = 'test-file.pdf';
     $file->write();
     $obj = $this->objFromFixture('Page', 'content');
     $obj->Content = sprintf('<p><a href="[file_link,id=%d]">Working Link</a></p>', $file->ID);
     $obj->write();
     $this->assertTrue($obj->doPublish());
     // Confirm that it isn't marked as broken to begin with
     $obj->flushCache();
     $obj = DataObject::get_by_id("SiteTree", $obj->ID);
     $this->assertEquals(0, $obj->HasBrokenFile);
     $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = {$obj->ID}");
     $this->assertEquals(0, $liveObj->HasBrokenFile);
     // Delete the file
     $file->delete();
     // Confirm that it is marked as broken in both stage and live
     $obj->flushCache();
     $obj = DataObject::get_by_id("SiteTree", $obj->ID);
     $this->assertEquals(1, $obj->HasBrokenFile);
     $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = {$obj->ID}");
     $this->assertEquals(1, $liveObj->HasBrokenFile);
 }
Example #27
0
 public function cropnsave($id)
 {
     $basepath = app_path() . '/storage/uploads/';
     $jpeg_quality = 90;
     $src = $basepath . 'resize_' . $id;
     if (ImageModel::getImgTypeByExtension($id) == ImageModel::IMGTYPE_PNG) {
         $img_r = imagecreatefrompng($src);
     } else {
         $img_r = imagecreatefromjpeg($src);
     }
     $dst_r = ImageCreateTrueColor(Input::get('w'), Input::get('h'));
     imagecopyresampled($dst_r, $img_r, 0, 0, Input::get('x'), Input::get('y'), Input::get('w'), Input::get('h'), Input::get('w'), Input::get('h'));
     $filename = $basepath . 'crop_' . $id;
     imagejpeg($dst_r, $filename, $jpeg_quality);
     $image = ImageModel::createImageModel('crop_' . $id);
     try {
         $session = Session::get('user');
         $userService = new SoapClient(Config::get('wsdl.user'));
         $currentUser = $userService->getUserById(array("userId" => $session['data']->id));
         $currentUser = $currentUser->user;
         $currentUser->avatar = $image;
         $result = $userService->updateUser(array("user" => $currentUser));
         // Cleanup
         File::delete($src);
         File::delete($filename);
         File::delete($basepath . $id);
         return Response::json($result->complete);
     } catch (Exception $ex) {
         error_log($ex);
     }
 }
 public function actualizarMisionVision()
 {
     $response = 0;
     $id_centro = e(Input::get('id_centro'));
     $mision_centro = e(Input::get('mision_centro'));
     $vision_centro = e(Input::get('vision_centro'));
     $quienes_somos_centro = e(Input::get('quienes_somos_centro'));
     $centro = Centro::buscar_centro($id_centro);
     if (!is_null(Input::file('img_centro'))) {
         $file_img_vieja = $centro->img_centro;
         $file_img_centro = Input::file('img_centro');
         $img_centro = $file_img_centro->getClientOriginalName();
     } else {
         $img_centro = $centro->img_centro;
     }
     $response = Centro::actualizar_centro_mision_vision_quienes($id_centro, $mision_centro, $vision_centro, $quienes_somos_centro, $img_centro);
     if ($response == 1) {
         if (!is_null(Input::file('img_centro'))) {
             $file_img_centro->move('img', $file_img_centro->getClientOriginalName());
             File::delete('img/' . $file_img_vieja);
         }
         return Redirect::to(URL::previous())->with('mensaje', 'Centro de Investigacion Actualizado Insertado Correctamente');
     } else {
         return Redirect::to(URL::previous())->with('mensaje', 'Ha ocurrido un error');
     }
 }
 public static function boot()
 {
     parent::boot();
     ProductReview::deleting(function ($productReview) {
         File::delete($productReview->image);
     });
 }
Example #30
-1
 public function postimage(Request $request)
 {
     $user = User::whereId(Auth::user()->id)->first();
     $path = public_path() . '/images/profiles/';
     $currentimage = $path . $user->avatar;
     if ($user->avatar != 'default.png') {
         \File::delete($currentimage);
     }
     if (Input::hasFile('file')) {
         $this->validate($request, ['file' => ['required', 'image']]);
         $file = Input::file('file');
         $filename = Auth::user()->id . '_' . time() . '.' . Input::file('file')->guessClientExtension();
         $img = Image::make($file);
         $img->fit(300, 300, function ($constraint) {
             $constraint->aspectRatio();
         })->save($path . $filename);
         $user->avatar = $filename;
         $user->save();
         return 'ok -' . $filename;
     } else {
         $user->avatar = 'default.png';
         $user->save();
         return redirect('/membres/profil/');
     }
 }