1. Christian Salazar
  2. YiiFileManager

Commits

christiansalazar  committed 9a34a96

rename_file method added

  • Participants
  • Parent commits 7743c9c
  • Branches master

Comments (0)

Files changed (2)

File IYiiFileManager.php

View file
 	public function get_file_path($id, $file_id, $extra=array());
 	public function get_file_info($id, $file_id, $extra=array());
 	public function can_read($id, $file_id, $extra=array());
+	public function rename_file($id, $file_id, $name, $extra=array());
 
 	function on_file($id, $file_id, $file_path, $extra=array());
 	function get_file_list($id, $extra=array());

File YiiDiskFileManager.php

View file
 		return null;
 	}
 
+	public function rename_file($id, $file_id, $name, $extra=array()){
+		$filedata = $this->get_file_info($id, $file_id, $extra);
+		$current_path = $this->get_file_path($id, $file_id, $extra);
+		$new_path = sprintf("%s/%s@%s",
+			$this->get_storage_path($id), $file_id, $name);
+		@copy($current_path,$new_path);
+		if(file_exists($new_path)){
+			@unlink($current_path);
+			return true;
+		}else
+		return false;
+	}
 }