⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

delete file



Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 10 December 2012 - 09:56 AM

I've installed crud in Codeigniter 1. I've changed model and control, removing "CI".

Then when I try to delete a file after you have uploaded, the file is not deleted. The symbol of the javascript runs constantly spinning. I examined with firebug and get a "page not found".

the file is not deleted from the folder, or database.

What could be the problem?

thank you very much

victor

victor
  • profile picture
  • Member

Posted 11 December 2012 - 22:32 PM

Hi Miguel Elendir and welcome to the forum!
May be this page really doesn't exist :)

victor

victor
  • profile picture
  • Member

Posted 11 December 2012 - 22:33 PM

show your path to function

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 12 December 2012 - 16:19 PM

where I have to create this page?
Where should this page?



This is my controller:



class Pitufo extends Controller {
function __construct()
{
parent::__construct();

$this->load->database();
$this->load->helper('url');

$this->load->library('grocery_CRUD');
}


function noticias_management()
{
$crud = new grocery_CRUD();
$crud->set_table('Noticias');
$crud->columns('not_titulo','not_descrip','not_fecha','not_ocultar','not_file');
$crud->display_as('not_titulo','Titulo de la Noticia');
$crud->display_as('not_descrip','Texto de la Noticia');
$crud->display_as('not_fecha','Fecha de la Noticia');
$crud->display_as('not_ocultar','Ocultar Noticia');
$crud->display_as('not_file','Imagen Asociada');
$crud->set_field_upload('not_file','img/news');


$output = $crud->render();

$this->_example_output($output);
}


Thanks for all

victor

victor
  • profile picture
  • Member

Posted 12 December 2012 - 16:23 PM

Can explain this: I've changed model and control, removing "CI".

victor

victor
  • profile picture
  • Member

Posted 12 December 2012 - 16:35 PM

In your case you should have this url:

http://your_site.com/index.php/pitufo/noticias_management/delete_file/not_file/image_name.jpg?_=1355333060290

Have a look at your url (on image).

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 12 December 2012 - 16:37 PM

Yes, my version of Codeigniter is 1.7 and I need to change "class Pitufo extends CI_Controller" to "class Pitufo extends Controller"

victor

victor
  • profile picture
  • Member

Posted 12 December 2012 - 16:41 PM

I didn't work with 1.7 version.
what is "Noti...te_file" in your url?
Is it method?

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 12 December 2012 - 16:44 PM

Ulr of my imagen is : http://tahonasanantonio.es/img/news/dd457-new_2.png

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 12 December 2012 - 16:46 PM

not_file is the field of table

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 12 December 2012 - 16:49 PM

I'll update the version of my Codeigniter. I've tried it and I mention if I still have the same problem
Thanks

victor

victor
  • profile picture
  • Member

Posted 12 December 2012 - 17:00 PM

show full url to your function

Miguel Elendir

Miguel Elendir
  • profile picture
  • Member

Posted 27 December 2012 - 11:04 AM

After updating Codeigniter. Everything works correctly. Thanks for everything.

Deeps

Deeps
  • profile picture
  • Member

Posted 10 March 2016 - 10:02 AM

same problem image not delete...... -_-

 

my controller:-

       
        $crud = new Grocery_CRUD();
        $crud->columns('story_id', 'name','partner_name','date_of_wedding','tell_story','photo',
                       'status','slug');
        
        $crud->display_as('story_id','Story Id');
        $crud->display_as('name','Name');
        $crud->display_as('partner_name','Partner Name');
        $crud->display_as('tell_story','Story');
        $crud->display_as('photo','Wedding Photo');
        $crud->display_as('status','Status');
        $crud->set_table('tbl_story');
        $crud->callback_column('date_of_wedding',array($this, 'callbackDob'));
        
        $crud->callback_after_insert(array($this,'story_slug'));
        $crud->callback_after_update(array($this,'story_slug'));
        $crud->callback_after_update(array($this, 'created_dtm_after_update'));
        $crud->callback_after_update(array($this,'callback_after_upload'));
    
        $crud->set_field_upload('photo',WEDDING_IMG_PATH);
        $crud->callback_after_upload(array($this,'callback_after_upload'));
    

        $crud->add_fields('name','partner_name','date_of_wedding','tell_story','photo','status');
        $crud->edit_fields('name','partner_name','date_of_wedding','tell_story','photo','status');
        $crud->required_fields('name','partner_name','date_of_wedding','tell_story','photo','status');
        $crud->order_by('created_dtm','dsc');
        $crud->field_type('date_of_wedding', 'date');
    
       
        $crud->set_subject('New Story');
        
        if($this->role == ROLE_SUBADMIN && $this->updations == ALLOW)
        {
            
            $crud->unset_upload();
            $crud->unset_delete();
            $crud->unset_add();
            $crud->unset_read();
        }
        else if($this->role == ROLE_ADMIN)
        {
            $crud->unset_read();
        
        }
        else
        {
            $crud->unset_delete();
            $crud->unset_add();
            $crud->unset_read();
            $crud->unset_edit();
            
        }
       
        $output = $crud->render();
        
        $this->storyOutput($output);
    
    }

function created_dtm_after_update($post_array,$primary_key)
         {
             $date_update = array(
                 "story_id" => $primary_key,
                 "created_dtm" => date('Y-m-d H:i:s')
             );
          
             $this->db->update('tbl_story',$date_update,array('story_id' => $primary_key));
          
             return true;
         }

       

 function callback_after_upload($uploader_response,$field_info, $files_to_upload)
{
    $this->load->library('image_moo');
 
    //Is only one file uploaded so it ok to use it with $uploader_response[0].
    $file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->photo;
 
    $this->image_moo->load($file_uploaded)->resize(800,600)->save($file_uploaded,true);
 
    return true;
}


Isra

Isra
  • profile picture
  • Member

Posted 19 November 2018 - 02:48 AM

Ensure to set properly this variable on your config.php file

$config['index_page'] = 'index.php';

In my case I changed and now "delete" link is working fine.