public function handleupload($savedir, $savefilename = null, $quotadata = array()) {
		if (!isset($_FILES['pdynfileuploader'])) {
			throw new Exception('No file received.', Exception::ERR_BAD_REQUEST);
		}

		if (empty($savedir) || !is_string($savedir)) {
			throw new Exception('Invalid save path received', Exception::ERR_BAD_REQUEST);
		}

		if (!is_writable($savedir)) {
			throw new Exception('Could not write to save path', Exception::ERR_BAD_REQUEST);
		}

		$file = new UploadedFile($_FILES['pdynfileuploader']);

		if (!empty($quotadata) && isset($quotadata['cursize']) && isset($quotadata['limit'])) {
			$newsize = (int)$quotadata['cursize'] + (int)$file->get_size();
			if ($newsize > $quotadata['limit']) {
				unlink($file->stored_filename);
				throw new Exception('Disk quota exceeded', Exception::ERR_BAD_REQUEST);
			}
		}

		if (empty($savefilename) || !is_string($savefilename)) {
			$ext = strtolower($file->get_original_extension());
			$savefilename = uniqid();
			if ($ext !== null) {
				$savefilename .= '.'.$ext;
			}
		}

		$savepath = $savedir.'/'.$savefilename;
		$file->save($savepath);

		$this->postprocess_file($file);

		return $file;
	}
public function handleupload($savedir, $savefilename = null, $quotadata = array()) {
		if (!isset($_FILES['pdynfileuploader'])) {
			throw new Exception('No file received.', Exception::ERR_BAD_REQUEST);
		}

		if (empty($savedir) || !is_string($savedir)) {
			throw new Exception('Invalid save path received', Exception::ERR_BAD_REQUEST);
		}

		if (!is_writable($savedir)) {
			throw new Exception('Could not write to save path', Exception::ERR_BAD_REQUEST);
		}

		$file = new UploadedFile($_FILES['pdynfileuploader']);

		if (!empty($quotadata) && isset($quotadata['cursize']) && isset($quotadata['limit'])) {
			$newsize = (int)$quotadata['cursize'] + (int)$file->get_size();
			if ($newsize > $quotadata['limit']) {
				unlink($file->stored_filename);
				throw new Exception('Disk quota exceeded', Exception::ERR_BAD_REQUEST);
			}
		}

		if (empty($savefilename) || !is_string($savefilename)) {
			$ext = strtolower($file->get_original_extension());
			$savefilename = uniqid();
			if ($ext !== null) {
				$savefilename .= '.'.$ext;
			}
		}

		$savepath = $savedir.'/'.$savefilename;
		$file->save($savepath);

		$this->postprocess_file($file);

		return $file;
	}
public function handleupload ( $ savedir , $ savefilename = null , $ quotadata = array ( ) ) { if ( ! isset ( $ _FILES [ 'pdynfileuploader' ] ) ) { throw new Exception ( 'No file received.' , Exception :: ERR_BAD_REQUEST ) ; } if ( empty ( $ savedir ) || ! is_string ( $ savedir ) ) { throw new Exception ( 'Invalid save path received' , Exception :: ERR_BAD_REQUEST ) ; } if ( ! is_writable ( $ savedir ) ) { throw new Exception ( 'Could not write to save path' , Exception :: ERR_BAD_REQUEST ) ; } $ file = new UploadedFile ( $ _FILES [ 'pdynfileuploader' ] ) ; if ( ! empty ( $ quotadata ) && isset ( $ quotadata [ 'cursize' ] ) && isset ( $ quotadata [ 'limit' ] ) ) { $ newsize = ( int ) $ quotadata [ 'cursize' ] + ( int ) $ file -> get_size ( ) ; if ( $ newsize > $ quotadata [ 'limit' ] ) { unlink ( $ file -> stored_filename ) ; throw new Exception ( 'Disk quota exceeded' , Exception :: ERR_BAD_REQUEST ) ; } } if ( empty ( $ savefilename ) || ! is_string ( $ savefilename ) ) { $ ext = strtolower ( $ file -> get_original_extension ( ) ) ; $ savefilename = uniqid ( ) ; if ( $ ext !== null ) { $ savefilename .= '.' . $ ext ; } } $ savepath = $ savedir . '/' . $ savefilename ; $ file -> save ( $ savepath ) ; $ this -> postprocess_file ( $ file ) ; return $ file ; }
Receive an uploaded file, validate it, and save it.

@param string $savedir A directory to save the file.
@param string $savefilename (Optional) A filename to save the file as, if empty, a unique name will be generated.
@return UploadedFile The resulting UploadedFile object.
Receive an uploaded file validate it and save it .