Ticket #414 (closed Bug: fixed)

Opened 8 months ago

Last modified 8 months ago

Form_Upload in Forge throws "Undefined variable: filepath"

Reported by: cufo Owned by: Shadowhand
Priority: trivial Milestone: 2.1.2
Component: Modules:Forge Version: SVN HEAD
Keywords: forge upload undefined variable Cc:

Description

	public function validate()
	{
		// The upload directory must always be set
		empty($this->directory) and $this->directory();

		// By default, there is no uploaded file
		$filename = '';

		if ($status = parent::validate() AND $this->upload['error'] === UPLOAD_ERR_OK)
		{
			// Set the filename to the original name
			$filename = $this->upload['name'];

			if (Config::item('upload.remove_spaces'))
			{
				// Remove spaces, due to global upload configuration
				$filename = preg_replace('/\s+/', '_', $this->data['value']);
			}

			if (file_exists($filepath = $this->directory.$filename))
			{
				if ($this->filename !== TRUE OR ! is_writable($filepath))
				{
					// Prefix the file so that the filename is unique
					$filepath = $this->directory.'uploadfile-'.uniqid(time()).'-'.$this->upload['name'];
				}
			}

			// Move the uploaded file to the upload directory
			move_uploaded_file($this->upload['tmp_name'], $filepath);
		}

		if ( ! empty($_POST[$this->data['name']]))
		{
			// Reset the POST value to the new filename
			$this->data['value'] = $_POST[$this->data['name']] = $filepath;
		}

		return $status;
	}

Change History

Changed 8 months ago by Shadowhand

  • keywords forge upload undefined variable added
  • status changed from new to assigned

Fixed

Changed 8 months ago by Shadowhand

  • summary changed from Form_Upload in Forge module raises a Runtime Message "Undefined variable: filepath" to Form_Upload in Forge throws "Undefined variable: filepath"

Fixed in r2115.

Changed 8 months ago by Shadowhand

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.