Example #1
0
 public function saveInto(DataObject $record)
 {
     $fieldName = $this->name . 'ID';
     $hasOnes = $record->has_one($this->name);
     // assume that the file is connected via a has-one
     if (!$hasOnes) {
         return;
     }
     $file = new File();
     $file->loadUploaded($_FILES[$this->name], $this->folderName);
     $record->{$fieldName} = $file->ID;
 }
 function createSubmittedField($data, $submittedForm, $fieldClass = "SubmittedFileField")
 {
     if (!$_FILES[$this->Name]) {
         return null;
     }
     $submittedField = new $fieldClass();
     $submittedField->Title = $this->Title;
     $submittedField->Name = $this->Name;
     $submittedField->ParentID = $submittedForm->ID;
     // create the file from post data
     $uploadedFile = new File();
     $uploadedFile->set_stat('file_size_restrictions', $this->stat('file_size_restrictions'));
     $uploadedFile->set_stat('allowed_file_types', $this->stat('allowed_file_types'));
     $uploadedFile->loadUploaded($_FILES[$this->Name]);
     $submittedField->UploadedFileID = $uploadedFile->ID;
     $submittedField->write();
     return $submittedField;
 }
Example #3
0
	/**
	 * Load a recently uploaded image into this image field.
	 * @param array $tmpFile The array entry from $_FILES
	 * @return boolean Returns true if successful
	 */
	function loadUploaded($tmpFile) {
		if(parent::loadUploaded($tmpFile) === true) {
			$this->deleteFormattedImages();
			return true;
		}
	}