本文整理汇总了PHP中File::Delete方法的典型用法代码示例。如果您正苦于以下问题:PHP File::Delete方法的具体用法?PHP File::Delete怎么用?PHP File::Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::Delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send(JustifFormRequest $request)
{
\Mail::send('emails.justificatif', array('username' => $request->get('username'), 'email' => $request->get('email'), 'justif' => $request->get('justificatif')), function ($message) use($request) {
$email = $request->email;
$username = $request->username;
$justif = $request->file('justificatif');
if ($justif->isValid()) {
$path = config('images.inscription');
$files = \File::files($path);
$newfile = $path . '/' . $username;
foreach ($files as $file) {
$fileWithoutExtension = substr($file, 0, -4);
if ($fileWithoutExtension === $newfile) {
\File::Delete($fileWithoutExtension . '.png');
\File::Delete($fileWithoutExtension . '.pdf');
\File::Delete($fileWithoutExtension . '.jpg');
}
}
$extension = $justif->getClientOriginalExtension();
$name = $username . '.' . $extension;
$justif->move($path, $name);
}
$file = $path . '/' . $name;
$message->attach($file);
$message->from($request->email);
$message->to('plateulere@gmail.com', 'Equipe Roadweb')->subject('envoi de justificatif');
$message->setReplyTo($email);
});
return \Redirect::route('compte')->with('message', 'Votre justificatif a bien été envoyé ! Vous serez informé de la validation de vos droits dans les 24 à 48h.');
}
示例2: deleteFileByField
public function deleteFileByField($value, $field)
{
global $settingsManager;
error_log("Delete file by field: {$field} / value: {$value}");
$file = new File();
$file->Load("{$field} = ?", array($value));
if ($file->{$field} == $value) {
$ok = $file->Delete();
if ($ok) {
$uploadFilesToS3 = $settingsManager->getSetting("Files: Upload Files to S3");
if ($uploadFilesToS3 == "1") {
$uploadFilesToS3Key = $settingsManager->getSetting("Files: Amazon S3 Key for File Upload");
$uploadFilesToS3Secret = $settingsManager->getSetting("Files: Amazone S3 Secret for File Upload");
$s3Bucket = $settingsManager->getSetting("Files: S3 Bucket");
$uploadname = CLIENT_NAME . "/" . $file->filename;
error_log("Delete from S3:" . $uploadname);
$s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
$res = $s3FileSys->deleteObject($s3Bucket, $uploadname);
} else {
error_log("Delete:" . CLIENT_BASE_PATH . 'data/' . $file->filename);
unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
}
} else {
return false;
}
}
return true;
}
示例3: deletePost
public function deletePost($deletePostId)
{
$deletePost = Posts::find($deletePostId);
if ($deletePost->photo != 'noImage.jpg') {
//delete the image associative with the post
\File::Delete('img/Post/' . $deletePost->photo);
}
$deletePost->delete();
return redirect('home');
}
示例4: deletePresentation
protected function deletePresentation($id, $presentationId)
{
if ($id == null || $presentationId == null) {
return Response::json('invalid ids', 400);
}
$Presentation = Presentation::where('Project_FK', '=', $id)->where('id', '=', $presentationId)->first();
if (empty($Presentation)) {
return Response::json('presentation is empty', 400);
}
\File::Delete(public_path() . "\\presentations\\" . $Presentation->file);
$Presentation->delete();
}
示例5: deleteProfileImage
public function deleteProfileImage($employeeId)
{
$file = new File();
$file->Load('name = ?', array('profile_image_' . $employeeId));
if ($file->name == 'profile_image_' . $employeeId) {
$ok = $file->Delete();
if ($ok) {
error_log("Delete File:" . CLIENT_BASE_PATH . $file->filename);
unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
} else {
return false;
}
}
return true;
}
示例6: deleteFileByField
public function deleteFileByField($value, $field)
{
$file = new File();
$file->Load("{$field} = ?", array($value));
if ($file->{$field} == $value) {
$ok = $file->Delete();
if ($ok) {
error_log("Delete:" . CLIENT_BASE_PATH . 'data/' . $file->filename);
unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
} else {
return false;
}
}
return true;
}
示例7: pictChange
public function pictChange(Request $request)
{
$pk = \Input::get('primkey');
$oldFile = \Input::get('profilpic');
$raport = Raport::find($pk);
$destinationPath = 'bower_components/dist/photos/students/' . $raport->angkatan;
// upload path
try {
\File::makeDirectory($destinationPath, 0755, true, true);
\File::Delete($oldFile);
if ($request->image != null) {
$extension = $request->image->getClientOriginalExtension();
// getting image extension
$fileName = $pk . '.' . $extension;
// renaming image
$request->image->move($destinationPath, $fileName);
// uploading file to given path
$raport->pict = '/' . $destinationPath . '/' . $fileName;
$raport->save();
} else {
$raport->pict = null;
}
} catch (\Illuminate\Database\QueryException $e) {
$request->session()->flash('alert-danger', 'Gagal Mengganti Foto');
}
return redirect()->back()->with('error', 'Failed');
}
示例8: updateCapture
public function updateCapture(Request $request, $id)
{
$this->validate($request, ['pokemon' => 'required|exists:pokemon,id', 'photo' => 'image']);
// Get info on the capture
$capture = Capture::findOrFail($id);
if ($request->hasFile('photo')) {
// Generate a new file name
$fileName = uniqid() . '.' . $request->file('photo')->getClientOriginalExtension();
\Image::make($request->file('photo'))->resize(320, null, function ($constraint) {
$constraint->aspectRatio();
})->save('img/captures/' . $fileName);
// Delete the old image
\File::Delete('img/captures/' . $capture->photo);
$capture->photo = $fileName;
}
if (\Carbon\Carbon::now()->diffInDays($capture->updated_at) > 5) {
if ($capture->attack < 350) {
$capture->attack += rand(0, 10);
if ($capture->attack > 350) {
$capture->attack = 350;
}
}
if ($capture->defense < 350) {
$capture->defense += rand(0, 10);
if ($capture->defense > 350) {
$capture->defense = 350;
}
}
}
$capture->pokemon_id = $request->pokemon;
$capture->save();
return redirect('pokecentre/captures');
}
示例9: destroy
/**
* Remove the specified Profiles from storage.
* @param int $id
* @return Response
*/
public function destroy($id)
{
$profiles = $this->profilesRepository->find($id);
if (empty($profiles)) {
Flash::error('Profiles not found');
return redirect(route('profiles.index'));
}
$docfrente = $profiles->docfrente;
$docverso = $profiles->docverso;
$foto = $profiles->foto;
if ($docfrente) {
if (\File::exists(base_path() . '/public/images/' . $docfrente)) {
\File::Delete(base_path() . '/public/images/' . $docfrente);
}
}
if ($docverso) {
if (\File::exists(base_path() . '/public/images/' . $docverso)) {
\File::Delete(base_path() . '/public/images/' . $docverso);
}
}
if ($foto) {
if (\File::exists(base_path() . '/public/images/' . $foto)) {
\File::Delete(base_path() . '/public/images/' . $foto);
}
}
$this->profilesRepository->delete($id);
Flash::success('Profiles deleted successfully.');
return redirect(route('profiles.index'));
}
示例10: update
/**
* Update the specified Companies in storage.
* @param int $id
* @param UpdateCompaniesRequest $request
* @return Response
*/
public function update($id, UpdateCompaniesRequest $request)
{
$companies = $this->companiesRepository->find($id);
if (empty($companies)) {
Flash::error('Companies not found');
return redirect(route('companies.index'));
}
$name = Input::file('logo')->getClientOriginalName();
if (isset($name)) {
\File::Delete(base_path() . '/public/images/' . $companies->logo);
Image::make(Input::file('logo'))->save(base_path() . '/public/images/' . $name);
$company = $this->companiesRepository->updateRich(['company' => $request->input('company'), 'logo' => $name], $id);
} else {
$companies = $this->companiesRepository->updateRich($request->all(), $id);
}
Flash::success('Companies updated successfully.');
return redirect(route('companies.index'));
}
示例11: Create
public function Create($post_name, $user_id, $id_word = null, $id_rewrite = false)
{
$user_id = (int) $user_id;
if (!POSTGood($post_name, self::$formats)) {
return 1;
}
if ($id_word and !preg_match("/^[a-zA-Z0-9._-]+\$/", $id_word)) {
return 3;
}
$new_file_info = POSTSafeMove($post_name, $this->base_dir);
if (!$new_file_info) {
return 2;
}
$way = $this->base_dir . $new_file_info['tmp_name'];
$hash = md5_file($this->base_dir . $new_file_info['tmp_name']);
$sql_part = $id_word ? " OR `id_word`=:id_word" : '';
$data = $id_word ? array('id_word' => $id_word) : false;
$line = getDB()->fetchRow("SELECT `id` FROM `{$this->db}` " . "WHERE `hash`='" . $hash . "'" . $sql_part, $data, 'num');
if ($line) {
$file_similar = new File($line[0]);
$similar_info = $file_similar->getInfo();
if ($similar_info['hash'] == $hash) {
if (file_exists($way)) {
unlink($way);
}
$this->id = $similar_info['id'];
$this->user_id = $similar_info['user_id'];
$this->id_word = $similar_info['id_word'];
$this->name = $similar_info['name'];
$this->size = $similar_info['size'];
$this->hash = $similar_info['hash'];
$this->downloads = $similar_info['downloads'];
$this->way = $file_similar->getWay();
return 7;
} else {
if (!$id_rewrite) {
if (file_exists($way)) {
unlink($way);
}
return 4;
} else {
if (!$file_similar->Delete()) {
return 6;
}
unset($file_similar);
}
}
}
$sql = "INSERT INTO {$this->db} (id_word, user_id, way, name, size, hash) " . "VALUES (:id_word, :user_id, :fway, :fname, :fsize, '{$hash}')";
$result = getDB()->ask($sql, array('id_word' => $id_word ? $id_word : '', 'user_id' => $user_id, 'fway' => $new_file_info['tmp_name'], 'fname' => $new_file_info['name'], 'fsize' => $new_file_info['size_mb']));
if ($result) {
$this->id = getDB()->lastInsertId();
$this->user_id = $user_id;
$this->id_word = $id_word ? $id_word : '';
$this->way = $way;
$this->name = $new_file_info['name'];
$this->size = $new_file_info['size_mb'];
$this->hash = $hash;
$this->downloads = 0;
} else {
if (file_exists($way)) {
unlink($way);
}
return 5;
}
return 0;
}
示例12: destroy
/**
* Remove the specified Musclegroups from storage.
* @param int $id
* @return Response
*/
public function destroy($id)
{
$musclegroups = $this->musclegroupsRepository->find($id);
if (empty($musclegroups)) {
Flash::error('Musclegroups not found');
return redirect(route('musclegroups.index'));
}
$icone = $musclegroups->icone;
if ($icone) {
if (\File::exists(base_path() . '/public/images/' . $icone)) {
\File::Delete(base_path() . '/public/images/' . $icone);
}
}
$this->musclegroupsRepository->delete($id);
Flash::success('Musclegroups deleted successfully.');
return redirect(route('musclegroups.index'));
}
示例13: destroy
/**
* Remove the specified Productphotos from storage.
* @param int $id
* @return Response
*/
public function destroy($id)
{
$productphotos = $this->productphotosRepository->find($id);
if (empty($productphotos)) {
Flash::error('Productphotos not found');
return redirect(route('productphotos.index'));
}
$foto = $productphotos->foto;
if ($foto) {
if (\File::exists(base_path() . '/public/images/' . $foto)) {
\File::Delete(base_path() . '/public/images/' . $foto);
}
}
$this->productphotosRepository->delete($id);
Flash::success('Productphotos deleted successfully.');
return redirect(route('productphotos.index'));
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $slug)
{
// Validation
$this->validate($request, ['first_name' => 'required|min:2|max:20', 'last_name' => 'required|min:2|max:30', 'age' => 'required|between:0,130|integer', 'profile_image' => 'image|between:0,2000']);
// Find the user or staff member to edit where slug is equal to whatever came back from the form
$staffMember = Staff::where('slug', $slug)->firstOrFail();
// Makes changes to the database
$staffMember->first_name = $request->first_name;
$staffMember->last_name = $request->last_name;
$staffMember->age = $request->age;
// Referencing the existing slug and assigning to it the new slug based on changes made to the staff members name
$staffMember->slug = str_slug($request->first_name . ' ' . $request->last_name);
// If the user provided a new image then save that image
if ($request->hasFile('profile_image')) {
// Change the image file name, move the image file and resize the image
// Grab the file extension of the image
$fileExtension = $request->file('profile_image')->getClientOriginalExtension();
// Generate a new profile image name to avoid duplication and join the two together
// ^ ^
$fileName = 'staff-' . uniqid() . '.' . $fileExtension;
// -
$request->file('profile_image')->move('img/staff', $fileName);
// Grabbed the profile image and resized it
\Image::make('img/staff/' . $fileName)->resize(240, null, function ($constrait) {
$constrait->aspectRatio();
})->save('img/staff/' . $fileName);
// Delete the old image
\File::Delete('img/staff/' . $staffMember->profile_image);
// Tell the database of the new image
$staffMember->profile_image = $fileName;
}
// Save the changes to the database
$staffMember->save();
// Redirect user to the staff members page with the updated changes
return redirect('about/' . $staffMember->slug);
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required']);
if ($validator->fails()) {
$messages = $validator->messages();
return redirect::route('agent_edit', $id)->withErrors($validator)->withInput();
} else {
$agent = Agent::find($id);
$first_name = $request->input('first_name');
$last_name = $request->input('last_name');
$password = $request->input('password');
$phone = $request->input('phone');
$agent->first_name = $first_name;
$agent->last_name = $last_name;
if ($phone) {
$agent->phone = $phone;
}
if ($password != '') {
$agent->password = $password;
}
if ($request->file('user_image')) {
$file = Input::file('user_image');
$imagename = time() . '.' . $file->getClientOriginalExtension();
if (file_exists(public_path('upload/agentprofile/' . $agent->image)) && $agent->image != '') {
$image_path = public_path('upload/agentprofile/' . $agent->image);
$image_thumb_path = public_path('upload/agentprofile/thumb/' . $agent->image);
\File::Delete($image_path);
\File::Delete($image_thumb_path);
}
$path = public_path('upload/agentprofile/' . $imagename);
$image = \Image::make($file->getRealPath())->save($path);
$th_path = public_path('upload/agentprofile/thumb/' . $imagename);
$image = \Image::make($file->getRealPath())->resize(128, 128)->save($th_path);
$agent->image = $imagename;
}
$agent->save();
return redirect::route('agent_management')->with('success', 'Agent updated successfully.');
}
}