$user = $hook->getValue('register.user');
$profile = $user->getOne('Profile');
$max_file_size = 30000; // size in bytes
$max_height=100;
$max_width=100;
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); //allowed file name extensions
$errors = array(1 => 'php.ini max file size exceeded',
2 => 'html form max file size exceeded',
3 => 'file upload was only partial',
4 => 'no file was attached');
$fieldname = 'profilePicture';
//check for internal PHP errors with the file
($_FILES[$fieldname]['error'] == 0)
or hook->addError($errors[$_FILES[$fieldname]['error']], 'internal errors exist with the file');
$uploadsDirectory = MODX_BASE_URL."members/";
//check to see if file was actually an image
@getimagesize($_FILES[$fieldname]['tmp_name'])
or hook->addError('Image', 'The uploaded file is not an image');
//get the width and height of the image
list($width, $height) = getimagesize($_FILES[$fieldname]['tmp_name']);
if(isset($width) && isset($height) && ($width >= $max_width || $height >= $max_height))
{
hook->addError('Image Size', 'Image size should be 100*100');
}
//make a unique filename for the file and check to see that it does not already exist
$username=profile->get('username');
$uploadFolderName=$uploadsDirectory.'$username';
if(!is_dir ( $uploadFolderName ))
{
mkdir($uploadFolderName);
}
$uploadFileName=$uploadsDirectory.'profilePic';
//move the file to the user images directory
@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)
// get the array of extended user profile attributes
$extended = $profile->get('extended');
$photo =$profile->get('photo');
$photo=$uploadFilename
$profile->set('photo', $photo);
$profile->save();
$user->save();
return true;
// add the value of the element for key `authorPhoto`
/*
$extended['authorPhoto'] = $_FILES['userfile']['name'];
$profile->set('extended', $extended);
$profile->save();
*/
[[!Register?&submitVar=`registerbtn`&submittedResourceId=`16` & postHooks=`uploadFiles` &usergroups=`Members` &activation=`1` &validate=`password2:password_confirm=^password^`]]

<?php
/* @var $user modUser */
$user = $hook->getValue('register.user');
$profile = $user->getOne('Profile');
$max_file_size = 30000; // size in bytes
$max_height=100;
$max_width=100;
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); //allowed file name extensions
$errors = array(1 => 'php.ini max file size exceeded',
2 => 'html form max file size exceeded',
3 => 'file upload was only partial',
4 => 'no file was attached');
$fieldname = 'profilePicture';
//check for internal PHP errors with the file
($_FILES[$fieldname]['error'] == 0)
or $hook->addError($errors[$_FILES[$fieldname]['error']], 'internal errors exist with the file');
$uploadsDirectory = MODX_BASE_URL."members/";
//check to see if file was actually an image
@getimagesize($_FILES[$fieldname]['tmp_name'])
or $hook->addError('Image', 'The uploaded file is not an image');
//get the width and height of the image
list($width, $height) = getimagesize($_FILES[$fieldname]['tmp_name']);
if(isset($width) && isset($height) && ($width >= $max_width || $height >= $max_height))
{
$hook->addError('Image Size', 'Image size should be 100*100');
}