Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:27:19+00:00 2026-06-11T17:27:19+00:00

I have the following code for file upload using grocery CRUD function test(){ $crud=new

  • 0

I have the following code for file upload using grocery CRUD

function test(){
        $crud=new grocery_CRUD();       
        $crud->set_table('test');
        $crud->add_fields('name', 'image');
        $crud->set_field_upload('image', 'test');
        $crud->callback_before_upload('image', array($this, 'before_test_upload'));
        $output=$crud->render();
        $output->page_title="Test Page";
        $this->_crud_output($output);       
    }
function before_test_upload($files_to_upload, $field_info){
        // Here I want to check the file format before that file upload to source folder.
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:27:21+00:00Added an answer on June 11, 2026 at 5:27 pm

    Yes, Have you tried with following way:

    function employees_management()
    {
        $crud = new grocery_CRUD();
    
    
        $crud->set_table('employees');
        $crud->set_relation('officeCode','offices','city');
        $crud->display_as('officeCode','Office City');
        $crud->set_subject('Employee');
    
        $crud->set_field_upload('file_url','assets/uploads/files');
        $crud->callback_before_upload(array($this,'example_callback_before_upload'));
    
        $output = $crud->render();
    
        $this->_example_output($output);
    }    
    
    
    function example_callback_before_upload($files_to_upload,$field_info)
    {
    /*
     * Examples of what the $files_to_upload and $field_info will be:    
    $files_to_upload = Array
    (
            [sd1e6fec1] => Array
            (
                    [name] => 86.jpg
                    [type] => image/jpeg
                    [tmp_name] => C:\wamp\tmp\phpFC42.tmp
                    [error] => 0
                    [size] => 258177
            )
    
    )
    
    $field_info = stdClass Object
    (
            [field_name] => file_url
            [upload_path] => assets/uploads/files
            [encrypted_field_name] => sd1e6fec1
    )
    
    */
    
        foreach($files_to_upload as $value) {
            $ext = pathinfo($value['name'], PATHINFO_EXTENSION);
        }
    
        $allowed_formats = array("jpg","gif");
        if(in_array($ext,$allowed_formats))
        {
            return true;
        }
        else
        {
            return 'Wrong file format';    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html code to upload an image: <input type=file name=before size=40>
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I am using the following code, upload.php, to try to have someone upload a
I have the following code to upload a pdf file through ftp : try
I have download the code for OpenFileDialog (File Upload function) from Silverlight tutorials website.
Can I use the following jQuery code to perform file upload using POST method
I am trying to upload file to rackspace cloud file using the following code:
I have the following code which posts file to ASP.net page: using (var Client
I have the following code: private function uploadFile(file:File, packageId:String):void { try { var fullpath:String
I am trying to upload file using dropbox api but following Code shows some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.