Changeset 2102 for releases/2.1.2/modules/forge/libraries/Form_Upload.php
- Timestamp:
- 02/21/2008 06:52:42 PM (11 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
releases/2.1.2/modules/forge/libraries/Form_Upload.php
r1923 r2102 23 23 protected $upload; 24 24 25 // Upload directory 25 // Upload directory and filename 26 26 protected $directory; 27 protected $filename; 27 28 28 public function __construct($name )29 public function __construct($name, $filename = FALSE) 29 30 { 30 31 parent::__construct($name); … … 39 40 // Hack to allow file-only inputs, where no POST data is present 40 41 $_POST[$name] = $this->upload['name']; 42 43 // Set the filename 44 $this->filename = empty($filename) ? FALSE : $filename; 41 45 } 42 46 else … … 91 95 } 92 96 97 if (file_exists($filepath = $this->directory.$filename)) 98 { 99 if ($this->filename !== TRUE OR ! is_writable($filepath)) 100 { 101 // Prefix the file so that the filename is unique 102 $filepath = $this->directory.'uploadfile-'.uniqid(time()).'-'.$this->upload['name']; 103 } 104 } 105 93 106 // Move the uploaded file to the upload directory 94 move_uploaded_file($this->upload['tmp_name'], $file name = $this->directory.$filename);107 move_uploaded_file($this->upload['tmp_name'], $filepath); 95 108 } 96 109 … … 98 111 { 99 112 // Reset the POST value to the new filename 100 $this->data['value'] = $_POST[$this->data['name']] = $file name;113 $this->data['value'] = $_POST[$this->data['name']] = $filepath; 101 114 } 102 115
