I am using chronoforms 3.1 RC4.11.
I am trying to use a form to upload files and then move the files to a new location based on the user that is uploading. I found the other posts that give the solution to this, but I can't get it to work. There seems to be a problem with using the $attachments array in the OnSubmit box. I inserted a debug message that should print out the path stored in the array, but nothing is shown. My files upload correctly to the original path, but they are not moved to the new folder. The new folders are created correctly and permissions are set correctly.
Here is what I have in the OnSubmit after email box.
Do you have an idea as to what I might be doing wrong? Thanks.
I am trying to use a form to upload files and then move the files to a new location based on the user that is uploading. I found the other posts that give the solution to this, but I can't get it to work. There seems to be a problem with using the $attachments array in the OnSubmit box. I inserted a debug message that should print out the path stored in the array, but nothing is shown. My files upload correctly to the original path, but they are not moved to the new folder. The new folders are created correctly and permissions are set correctly.
Here is what I have in the OnSubmit after email box.
<?php
// set field names for your form
$field_name = 'file_1';
$user =& JFactory::getUser();
// set the path to save to
$target_folder = JPATH_SITE.DS.'images'.DS.'uploads'.DS.$user->username.DS.headshot;
// create the target folder if it doesn't exist
if ( !JFolder::exists($target_folder) ) {
JFolder::create($target_folder);
}
// get the file name
$filename = basename($attachments[$field_name]);
$MyForm->addDebugMsg($attachments[$field_name].' mydebugmsg');
// check that the file exists and move it
if ( JFile::exists($attachments[$field_name]) ) {
JFile::move($attachments[$field_name], $target_folder.DS.$filename);
}
?>
Do you have an idea as to what I might be doing wrong? Thanks.