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


PHP Files::deleteFile方法代码示例

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


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

示例1: noavatarAction

 public function noavatarAction()
 {
     $files = new Files();
     $file = $this->_properties->getProperty('avatar_image');
     $this->_properties->deleteProperty('avatar_image');
     $files->deleteFile($file);
     $this->_forward('index');
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:8,代码来源:ProfileController.php

示例2: uploadimageAction

 public function uploadimageAction()
 {
     // Where we come from
     $source = $this->_getParam('source');
     // Verify that it is authorized
     if (!in_array($source, array('design', 'profile'))) {
         throw new Stuffpress_Exception("Invalid source specified {$source}");
     }
     // What are we uploading
     $image = $this->_getParam('image');
     $property = "{$image}_image";
     // Was a file uploaded ?
     if (!isset($_FILES['file'])) {
         $this->addErrorMessage('Upload failed: no files received on server end.');
         return $this->_forward('index', $source, 'admin');
     }
     // Validate the uploaded file
     $tmp_file = $_FILES['file']['tmp_name'];
     $file_name = basename($_FILES['file']['name']);
     $file_type = $_FILES['file']['type'];
     $file_ext = substr(trim(substr($file_name, strrpos($file_name, '.')), '.'), 0, 4);
     // returns the ext only
     // Check file size
     if ($_SERVER['CONTENT_LENGTH'] > 2000000) {
         $this->addErrorMessage('Upload failed: your file size is above 2Mbytes.');
         return $this->_forward('index', $source, 'admin');
     }
     // Check file extension
     if (!in_array(strtolower($file_ext), array("gif", "jpg", "png", "jpeg"))) {
         $this->addErrorMessage('Upload failed: we only support jpg, gif and png files.');
         return $this->_forward('index', $source, 'admin');
     }
     // Assign a random name to the file
     $key = Stuffpress_Token::create(32);
     $root = Zend_Registry::get("root");
     $uploaddir = $root . "/upload/";
     $uploadfile = $uploaddir . '/' . $key;
     // Move the file to the upload folder
     if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
         $this->addErrorMessage('Upload failed: your file size is above 2Mbytes.');
         return $this->_forward('index', $source, 'admin');
     }
     // Store the file in the database
     $files = new Files(array(Stuffpress_Db_Table::USER => $this->_application->user->id));
     $file_id = $files->addFile($key, $file_name, "Lifestream custom image", $file_type, $file_ext);
     // Build a thumbnail of the file
     try {
         $files->fitSquare($file_id, 75, 'thumbnails');
     } catch (Exception $e) {
         $message = $e->getMessage();
         $this->addErrorMessage("Upload failed: could not process image ({$message})");
         $files->deleteFile($key);
         return $this->_forward('index', $source, 'admin');
     }
     // Replace the user property with the new file and delete the older one
     $properties = new Properties(array(Properties::KEY => $this->_application->user->id));
     $old_file = $properties->getProperty($property);
     $properties->setProperty($property, $key);
     if ($old_file) {
         $files->deleteFile($old_file);
     }
     // If we are here, everything went smooth
     $this->addStatusMessage('Your file was successfully uploaded');
     return $this->_forward('index', $source, 'admin');
 }
开发者ID:segphault,项目名称:storytlr,代码行数:65,代码来源:FileController.php

示例3: deleteAction

	public function deleteAction() {
		// Get, check and setup the parameters
		$item_id = $this->getRequest()->getParam("id");
		
		// Get the source
		$source_id	= $this->_properties->getProperty('stuffpress_source');
		
		//Verify if the requested item exist
		$data		= new Data();
		if (!($item	= $data->getItem($source_id, $item_id))) {
			throw new Stuffpress_NotFoundException("This item does not exist.");
		}
		
		// Get the user
		$users 			= new Users();
		$attributes		= $item->getAttributes();
		$user			= $users->getUser($attributes['user_id']);
		
		// Check if we are the owner
		if ($this->_application->user->id != $user->id) {
			throw new Stuffpress_NotFoundException("Not the owner");
		}
				
		// Create the source
		$source		= StuffpressModel::forUser($user->id);
		
		// If an image or audio file, delete the files
		$file = $item->getFile();
		if ($file) {
			$files = new Files();
			$files->deleteFile($file);
		}
		
		// All checks ok, we can delete !
		$data->deleteItem($source_id, $item_id);
		$source->deleteItem($item_id);

		// We should also delete the associated comments
		$comments = new Comments();
		$comments->deleteComments($source->getID(), $item_id);

		// return that everything is fine
		return $this->_helper->json->sendJson(true);
	}
开发者ID:rjdjohnston,项目名称:core,代码行数:44,代码来源:PostController.php

示例4: setcoverAction

 public function setcoverAction()
 {
     // Get, check and setup the parameters
     $story_id = $this->getRequest()->getParam("story");
     $source_id = $this->getRequest()->getParam("source");
     $item_id = $this->getRequest()->getParam("item");
     //Verify if the requested story exist
     $stories = new Stories();
     if (!($story = $stories->getStory($story_id))) {
         return $this->_helper->json->sendJson(false);
     }
     // Check if we are the owner
     if ($this->_application->user->id != $story->user_id) {
         return $this->_helper->json->sendJson(false);
     }
     //Verify if the requested source exist
     $sources = new Sources();
     if (!($source = $sources->getSource($source_id))) {
         return $this->_helper->json->sendJson(false);
     }
     // Check if we are the owner
     if ($this->_application->user->id != $source['user_id']) {
         return $this->_helper->json->sendJson(false);
     }
     //Verify if the requested item exist
     $data = new Data();
     if (!($item = $data->getItem($source_id, $item_id))) {
         return $this->_helper->json->sendJson(false);
     }
     // Do we have a url ?
     if (!($url = $item->getImageUrl(ImageItem::SIZE_MEDIUM))) {
         return $this->_helper->json->sendJson(false);
     }
     // Get the old image and delete it
     $files = new Files();
     if ($file = $files->getFileFromKey($story->thumbnail)) {
         $files->deleteFile($file->key);
     }
     // Ok, we can set the image
     $this->setKeyImage($story_id, $url);
     return $this->_helper->json->sendJson(true);
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:42,代码来源:StoryController.php

示例5: deleteTableRow

 /**
  * Удаление записей из таблицы
  * @param string $table
  * @param int $id
  * @param array $files
  * @return mixed
  */
 public function deleteTableRow($table, $id, $files = array('image', 'icon', 'file'))
 {
     // Удаление файлов
     if (is_array($files) && !empty($files)) {
         $data = $this->getAllChildren($table, $id);
         for ($i = 0; $i < count($data); $i++) {
             foreach ($files as $value) {
                 if (isset($data[$i][$value]) && $data[$i][$value] != '') {
                     Files::deleteFile($data[$i][$value]);
                 }
             }
         }
     }
     // Получение ветвей дерева
     $tree_branches = $this->getNodeInfo($table, $id);
     $query = 'CALL delete_tree_table_rows(:current_table, :tree_left, :tree_right)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':tree_left' => $tree_branches['tree_left'], ':tree_right' => $tree_branches['tree_right']);
     PdoWrap::execute($query, $params);
     // Clearing blank spaces in a tree
     $query = 'CALL update_tree_branches_after_delete(:current_table, :tree_left, :tree_right)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':tree_left' => $tree_branches['tree_left'], ':tree_right' => $tree_branches['tree_right']);
     PdoWrap::execute($query, $params);
     // Логирование оперции
     $this->tableLog(PREF . $table, $id, "3");
 }
开发者ID:klimjr,项目名称:cms,代码行数:32,代码来源:class.TreeTable.php

示例6: clearimageAction

 public function clearimageAction()
 {
     // What are we deleting ?
     $image = $this->_getParam('image');
     $property = "{$image}_image";
     // Delete file and property
     $files = new Files();
     $file = $this->_properties->getProperty($property);
     $this->_properties->deleteProperty($property);
     if ($file) {
         $files->deleteFile($file);
     }
     return $this->_helper->json->sendJson(false);
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:14,代码来源:DesignController.php

示例7: SourcesProperties

        // Delete the source settings
        $properties = new SourcesProperties(array(Properties::KEY => $source['id']));
        $properties->deleteAllProperties();
        // Remove the source
        $sdb->deleteSource($source['id']);
        // We should also delete the associated comments
        $comments = new Comments();
        $comments->deleteComments($source['id']);
    }
}
// Delete all user files
$fdb = new Files();
$files = $fdb->getFiles();
if ($files && count($files) > 0) {
    foreach ($files as $file) {
        $fdb->deleteFile($file->key);
    }
}
// Delete all stories
$stdb = new Stories();
$stories = $stdb->getStories();
if ($stories && count($stories) > 0) {
    foreach ($stories as $story) {
        $stdb->deleteStory($story['id']);
    }
}
// Delete all widgets
$wdb = new Widgets();
$widgets = $wdb->getWidgets();
if ($widgets && count($widgets) > 0) {
    foreach ($widgets as $widget) {
开发者ID:kreativmind,项目名称:storytlr,代码行数:31,代码来源:delete.php

示例8: _deleteFileFromDb

 protected function _deleteFileFromDb($key)
 {
     $files = new Files();
     $files->deleteFile($key);
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:5,代码来源:BaseController.php

示例9: deleteTableRow

 /**
  * Удаление записей из таблицы
  * @param $table
  * @param $id
  * @param array $files
  * @return mixed
  */
 public function deleteTableRow($table, $id, $files = array('image', 'icon', 'file'))
 {
     // Удаление файлов
     if (is_array($files) && !empty($files)) {
         $data = $this->getRowById($table, $id);
         foreach ($files as $value) {
             if (isset($data[$value]) && $data[$value] != '') {
                 Files::deleteFile($data[$value]);
             }
         }
     }
     $query = 'CALL delete_table_row_by_field(:current_table, :table_cell, :cell_value)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':table_cell' => 'id', ':cell_value' => $id);
     PdoWrap::execute($query, $params);
     // Логирование оперции
     $this->tableLog(PREF . $table, $id, "3");
 }
开发者ID:klimjr,项目名称:cms,代码行数:24,代码来源:class.SimpleTable.php

示例10: deleteRow

 /**
  * Удаление записи из таблицы
  * @param string $table
  * @param int $id
  * @return bool
  */
 public function deleteRow($table, $id)
 {
     parent::deleteRow($table, $id);
     // Удаление характеристик
     $query = 'CALL catalog_features_values_delete(:field_item_id)';
     $params = array(':field_item_id' => $id);
     PdoWrap::execute($query, $params);
     // Удаление изображений
     $images = $this->__getImages($id);
     for ($i = 0; $i < count($images); $i++) {
         Files::deleteFile($images[$i]['image']);
     }
     $query = 'CALL catalog_images_delete(:item_id)';
     $params = array(':item_id' => $id);
     PdoWrap::execute($query, $params);
 }
开发者ID:klimjr,项目名称:cms,代码行数:22,代码来源:class.catalog.php

示例11: Files

$username = $_SESSION['username'];
$oFiles = new Files();
$aUserFiles = $oFiles->getFiles($_SESSION['userid']);
$output = "<html>\n  <head>\n  <meta charset='utf-8'>\n  <title>User restricted- Area</title>\n  <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>\n  <script src='js/func.user_area.js' type='text/javascript'></script>\n</head>\n</html>\n<body>\nEingeloogt als User: " . $userid . "<strong> " . $username . "</strong>\n<a href='index.php?redirect=logout'>Logout</a>\n<br/>\n\n<div>\n<h2>File upload - overview</h2><br/>\n<form action='user_area.php?upload=1' method='post' name='upload' enctype='multipart/form-data'>\n Wählen Sie hier eine Datei, die Sie uploaden möchten:<br/>\n <input type='file' name='upload' size='100'>\n <input type='submit' name='fileuploader' value='Upload'>\n\n</form>\n</div>";
// here call function to insert new data
if (isset($_GET['upload'])) {
    $filename = $_FILES['upload']['name'];
    $type = $_FILES['upload']['type'];
    $size = $_FILES['upload']['size'];
    $created = date('Y-m-d H:i:s');
    $oFiles->newFile($filename, $type, $size, $created);
    header('Location: user_area.php');
}
// actions von GET abfragen
if (isset($_GET['action']) && $_GET['action'] == "delete") {
    $oFiles->deleteFile($_GET['id']);
    header('Location: user_area.php');
}
if (isset($_GET['renamed']) && isset($_POST['rename_frm_submit'])) {
    $oFiles->renameFile($_POST['fileid'], $_POST['oldfile'], $_POST['newname']);
    header('Location: user_area.php');
}
//show this only when file should be renamed
if (isset($_GET['action']) && $_GET['action'] == "rename") {
    $output .= "<div style='margin: 10px 10px; padding: 10px 10px; background-color: #CCC;' id='file_rename'>\n\t              <span id='close_div'><img src='icons/close.png' style='float:right;' title='close'></span>\n                  <form method='post' action='user_area.php?renamed=1' name='filerename'>\n                  <input type='hidden' name='fileid' value='" . $_GET['id'] . "'>\n                  <input type='hidden' name='oldfile' value='" . $oFiles->getFileNameById($_GET['id']) . "'>\n                  new filename: <input type='text' name='newname' maxlength='100' size='100' value='" . $oFiles->getFileNameById($_GET['id']) . "'><br>\n                  <input type='submit' value='rename' name='rename_frm_submit'>\n                  </form>\n                </div>";
}
//print_r($aUserFiles);
// show this, if user has files uploaded
if ($aUserFiles) {
    $output .= "<div class='filelist'>";
    $output .= "Hier sehen Sie alle Dateien, die Sie hochgeladen haben. <br>\n\t       Wenn Sie in die rechte Spalte auf das Icon klicken, können Sie die Datei löschen, mit dem Icon auf der mittleren Spalte <br>\n\t\t   können Sie es umbenennen. <br><br>";
开发者ID:sharamigo,项目名称:php_webprojects,代码行数:31,代码来源:user_area.php


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