Permalink
Browse files

BackwardsCompatibilityBreak - fUpload::upload() was renamed to fUploa…

…d::move()
  • Loading branch information...
wbond committed Oct 16, 2008
1 parent 987e1c5 commit 2c36cbf134c6a0a55de6a3373b89cf2d4e08ae88
Showing with 32 additions and 32 deletions.
  1. +1 −1 classes/fORMFile.php
  2. +31 −31 classes/fUpload.php
View
@@ -980,7 +980,7 @@ static public function upload($object, &$values, &$old_values, &$related_records
// Try to upload the file putting it in the temp dir incase there is a validation problem with the record
try {
$uploader = self::setUpFUpload($class, $column);
$file = $uploader->upload($temp_dir, $column);
$file = $uploader->move($temp_dir, $column);
// If there was an eror, check to see if we have an existing file
} catch (fExpectedException $e) {
View
@@ -1,6 +1,6 @@
<?php
/**
* Provides file upload functionality
* Provides validation and movement of uploaded files
*
* @copyright Copyright (c) 2007-2008 William Bond
* @author William Bond [wb] <will@flourishlib.com>
@@ -15,8 +15,8 @@
class fUpload
{
// The following constants allow for nice looking callbacks to static methods
const check = 'fUpload::check';
const count = 'fUpload::count';
const check = 'fUpload::check';
const count = 'fUpload::count';
/**
@@ -184,33 +184,7 @@ private function extractFileUploadArray($field, $index=NULL)
/**
* Sets the file mime types accepted, one per parameter
*
* @param string $size The maximum file size (ex: 1MB, 200K, 10.5M), 0 for no limit
* @return void
*/
public function setMaxFileSize($size)
{
$this->max_file_size = fFilesystem::convertToBytes($size);
}
/**
* Sets the file mime types accepted
*
* @param array $mime_types The mime types to accept
* @param string $message The message to display if the uploaded file is not one of the mime type specified
* @return void
*/
public function setMimeTypes($mime_types, $message)
{
$this->mime_types = $mime_types;
$this->mime_type_message = $message;
}
/**
* Handles a file upload
* Moves an uploaded file from the temp directory to a permanent location
*
* @throws fValidationException
*
@@ -219,7 +193,7 @@ public function setMimeTypes($mime_types, $message)
* @param integer $index If the field was an array file upload field, upload the file corresponding to this index
* @return fFile An fFile object
*/
public function upload($directory, $field, $index=NULL)
public function move($directory, $field, $index=NULL)
{
if (!is_object($directory)) {
$directory = new fDirectory($directory);
@@ -276,6 +250,32 @@ public function upload($directory, $field, $index=NULL)
}
/**
* Sets the file mime types accepted, one per parameter
*
* @param string $size The maximum file size (ex: 1MB, 200K, 10.5M), 0 for no limit
* @return void
*/
public function setMaxFileSize($size)
{
$this->max_file_size = fFilesystem::convertToBytes($size);
}
/**
* Sets the file mime types accepted
*
* @param array $mime_types The mime types to accept
* @param string $message The message to display if the uploaded file is not one of the mime type specified
* @return void
*/
public function setMIMETypes($mime_types, $message)
{
$this->mime_types = $mime_types;
$this->mime_type_message = $message;
}
/**
* Validates the uploaded file, ensuring a file was actually uploaded and that is matched the restrictions put in place
*

0 comments on commit 2c36cbf

Please sign in to comment.