But alas, still nothing is happening, I just get the generic 500 error. Here is my code. I haven't changed anything out of the box with SWFUpload, except setting debug to true in swfupload/_config.php:
* swfupload/code/SWFUploadControls.php (as is, out of the box)
class SWFUploadControls extends Controller
{
public static $image_class = "Image";
public static $file_class = "File";
public function handleswfupload()
{
if (isset($_FILES["swfupload_file"]) && is_uploaded_file($_FILES["swfupload_file"]["tmp_name"])) {
$ext = strtolower(end(explode('.', $_FILES['swfupload_file']['name'])));
$class = in_array($ext, array('jpg','jpeg','gif','png')) ? self::$image_class : self::$file_class;
$file = new $class();
$u = new Upload();
$dir = SWFUploadConfig::get_var('default_upload_dir');
if(!$dir) $dir = "Uploads";
$u->loadIntoFile($_FILES['swfupload_file'], $file, $dir);
$file->write();
echo $file->ID;
}
else {
echo ' '; // return something or SWFUpload won't fire uploadSuccess
}
}
}
* ssprojects/code/MessageForm.php (my custom form subclass)
class MessageForm extends Form
{
function __construct($controller, $name, $id = 0)
{
SWFUploadConfig::addFileTypes(array(
'pdf'
));
$fields = singleton('Message')->getFrontEndFields();
$fields->push(new HiddenField('ProjectId', 'ProjectId', $id));
$fields->push(new SWFUploadField($name, 'Files', 'Upload Message Files', array('file_upload_limit' => '1')));
$validators = new RequiredFields('Body');
$actions = new FieldSet(new FormAction('submit', 'Save Message'));
parent::__construct($controller, $name, $fields, $actions, $validators);
}
}
* ssprojects/code/Project.php (my controller and the method that gets the form)
class Project_Controller extends Page_Controller
{
function MessageForm($id = 0)
{
$params = $this->getURLParams();
if ($params['ID']) {
$id = (int)$params['ID'];
}
return new MessageForm($this, 'MessageForm', $id);
}
}
As I understand it, this should at least save a file to the Uploads directory, correct?