How to make upload image a required field?

ClassiBase classifieds script Forums General help How to make upload image a required field?

This topic contains 3 replies, has 2 voices, and was last updated by  Elite Tan 2 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1093 Reply

    Elite Tan
    Participant

    and Support, when post ad, the postcontroller php can make description a required field, but how about for img, what code do I need to add to force ad poster post at least 1 img or upload 1 image? please advice, many thanks 🙂

    #1094 Reply

    ClassiBase
    Keymaster

    This requires advanced PHP knowledge. You have to edit /sys/app/controllers/PostController.php file line 274.

    Add else statement to if like following

    if($uploads['num_files'])
    {
    ...
    }
    else
    {
    // no image uploaded then display error and prompt upload at least one image 
    $this->validation()->set_error(__('Please upload at least one image.'));
    
    // delete this ad
    $ad->delete();
    return $ad;
    }

    Remind you again that changes made to core files will be deleted on script update.

    #1675 Reply

    Elite Tan
    Participant

    Hi Support I’ve fresh installed latest v1.5 and using above code but it doesn’t work anymore please advice what’s the new code to make upload image at least 1 image compulsory, please let us know? Thanks……….

    #1676 Reply

    Elite Tan
    Participant

    Hi please ignore is a cache issue, after reboot it works 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: How to make upload image a required field?
Your information: