Fatal error: Call to a member function getFileID() on a non-object

Permalink
Hi, i'm still trying to get a file upload working for studio testimonial block, i've had no response from the dev himself so trying here.

I have added the code below, but am getting the error:

Fatal error: Call to a member function getFileID() on a non-object in /home/insure/public_html/packages/studio_testimonials_pro/blocks/studio_testimonials_pro/tools/submit_testimonial.php on line 17

not sure why its not creating an object any ideas greatly appreciated :)

$postdata = $_POST;
    Loader::library("file/importer");
    $fi = new FileImporter();
    $upimage = $fi->import($_FILES['image']['tmp_name'], $_FILES['image']['name']);
    Loader::model('file_set');
    $fs = FileSet::getByName('Test Uploads');
    $fsf = $fs->addFileToSet($upimage);
    $postdata['image'] = $upimage->getFileID();
    Loader::model('testimonial', 'studio_testimonials_pro');
    $res = Testimonial::add($postdata);

1 Attachment

BHWW
 
BHWW replied on at Permalink Reply
BHWW
Ok, so that part is now working, the issue was that I hadn't used: enctype="multipart/form-data" on my form :(

However the form is still not working as expected, it's an ajax validation issue I think, but not too sure...

Any ideas please?

<script type="text/javascript">
$(function(){
   $('#submit-testimonial-form').submit(function(e){
        e.preventDefault();
        var error = '';
        if($('#submit-testimonial-form #author').val() == ''){
            error = error + '<?php  echo t('Please enter an author.')?>\n';
        }   
        if($('#submit-testimonial-form #content').val() == ''){
            error = error + '<?php  echo t('Please enter a testimonial.')?>\n';
        }
        if(error != ''){
            alert(error);
        } else {
            $.post($('#submit-testimonial-form').attr('action'), $('#submit-testimonial-form').serialize(), function(res){


if i remove the validation it works, but if its there it fails :(
BHWW replied on at Permalink Reply
BHWW
Ok, if anyone else needs this.... I had to change the way the ajax form was submitted:

$.ajax({
                url: $(this).attr('action'),
                type: 'POST',
                data: formData,
                async: false,
                success: function (returndata) {
                alert('<?php  echo t('Thank you for your submission, bear with us while we review the details (just to make sure your photo isn’t too rude) and then it’ll appear on the website. Thanks!’.'); ?>')
                  $.fn.dialog.closeTop();
                },
                cache: false,
                contentType: false,
                processData: false
            });


But its all working now thanks to a few willing volunteers, thank you :)