⚠ 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

set_upload_field can't delete files



yourself
  • profile picture
  • Member

Posted 18 March 2013 - 10:18 AM

Hello!

 

I'm building an application using codeigniter and the wonderful grocery crud. The thing is that I encountered the following:

 

1. I have created a TEXT field in my mysql database named adContent, which is meant to store the location of a file through set_upload_field.

2. I have specified $crud->set_field_upload("adContent","assets/uploads/files/");

 

When I create a new record, I can upload a file, and it gets uploaded. If I then save the record, I can see the thumbnail in the table. My problem is that

if I try to edit the record and press "Delete" next to the uploaded image, it doesn't work! All I get is "Deleting" (translated in my current locale of course) and the spinning arrows next to it. It does not actually delete the file nor it allows me to upload another. Am I missing something?

 

Thanks!


tlc033
  • profile picture
  • Member

Posted 18 March 2013 - 14:02 PM

Hi and welcome on GC.

I has the same problem then i upload and edit/delete but in my case in DB i has field type VARCHAR (100) but my file name (uploaded image name) has more that 100 caracters.

 

I set VARCHAR (300) and it work.


yourself
  • profile picture
  • Member

Posted 19 March 2013 - 10:52 AM

Thanks tlc033 for your insight.

 

Unfortunately, setting VARCHAR(300) instead of TEXT did not solve my problem! What can I do to trace it down?

 

I'm using Netbeans and its internal PHP interpreter, if this makes a difference..


yourself
  • profile picture
  • Member

Posted 19 March 2013 - 11:57 AM

Ok, I've tried tracking down this issue, it seems that after clicking "Delete", the browser request this URL:

 

http://localhost:8001/ads/index/delete_file/adContent/1c4f0-marge.jpg?_=1363693760305

 

but it gets this:

 

Not Found

The requested resource /ads/index/delete_file/adContent/1c4f0-marge.jpg?_=1363693760305 was not found on this server.

 

any ideas why?


yourself
  • profile picture
  • Member

Posted 19 March 2013 - 15:45 PM

Even more data on this weird issue, if I click delete I get on chrome's javascript console an error on:

 

GET http://127.0.0.1:8001/index.php/ads/index/delete_file/adContent/50f29-asya09lkc.png?_=1363707673732

Even weirdier (after a lot of changes, especially not using rewriting and .htaccess), if copy paste the URL on my browser, everything works and I get

 

{"success":true}

 

and the file gets deleted. What gives?


davidoster
  • profile picture
  • Member

Posted 19 March 2013 - 18:36 PM

Hello and welcome to the forums.

Which version of Grocery CRUD have you downloaded?


yourself
  • profile picture
  • Member

Posted 19 March 2013 - 19:32 PM

Hello davidoster! I'm using 1.3.3.

 

By tracing a bit more the previous error, it happens here:

 

 

$.ajax({
                    url: delete_url+"/"+file_name,
                    cache: false,
                    success:function(){
                        show_upload_button(unique_id, uploader_element);
                    },
                    beforeSend: function(){
                        $('#upload-state-message-'+unique_id).html(string_delete_file);
                        $('#success_'+unique_id).hide();
                        $("#loading-"+unique_id).show();
                        $("#upload-button-"+unique_id).slideUp("fast");
                    }
                });

yourself
  • profile picture
  • Member

Posted 19 March 2013 - 21:20 PM

Furthermore, by modifying it to report the error:

          
$.ajax({
url: delete_url+"/"+file_name,
cache: false,
error: function(jqXHR,tS,eT) {
   alert(JSON.stringify(jqXHR));
},
success:function(){
   show_upload_button(unique_id, uploader_element);
},
beforeSend: function(){
   $('#upload-state-message-'+unique_id).html(string_delete_file);
   $('#success_'+unique_id).hide();
   $("#loading-"+unique_id).show();
   $("#upload-button-"+unique_id).slideUp("fast");
}
});
 

I get this:

 

{"readyState":0,"responseText":"","status":0,"statusText":"error"}


yourself
  • profile picture
  • Member

Posted 19 March 2013 - 21:39 PM

Even further, if I disable rewriting and use the traditional index.php urls, in firefox at least it seems to work.

 

My .htaccess is:

 

RewriteEngine on
RewriteCond $1 !^(index\.php|css|kcfinder|elfinder|assets|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
 
and I also have 
$config['index_page'] = 'index.php';
 
in my config.php

Martin Lobato
  • profile picture
  • Member

Posted 21 December 2016 - 19:11 PM

I have two functions doing the same thing, in one... it works fine, on second, I got this error. WTF??


Martin Lobato
  • profile picture
  • Member

Posted 22 December 2016 - 18:27 PM

welll.... when I upload any file type, like doc or pfd it works and delete clean. but when I upload a jpg or png... shows this error 

 

jquery-1.11.1.min.js:4 GET ....com/melic/publicaciones/delete_file/descripcion_larga/a3d83-10dof-2.jpg?_=1482430860899 404 (Not Found)

 

I've made some checks, and if I delete the letter g from jpg and png....  it is finding the function, I mean, 200 instead of 404... what it could be???? It is driving me crazy!!


Martin Lobato
  • profile picture
  • Member

Posted 22 December 2016 - 18:27 PM

welll.... when I upload any file type, like doc or pfd it works and delete clean. but when I upload a jpg or png... shows this error 

 

jquery-1.11.1.min.js:4 GET ....com/melic/publicaciones/delete_file/descripcion_larga/a3d83-10dof-2.jpg?_=1482430860899 404 (Not Found)

 

I've made some checks, and if I delete the letter g from jpg and png....  it is finding the function, I mean, 200 instead of 404... what it could be???? It is driving me crazy!!


Martin Lobato
  • profile picture
  • Member

Posted 21 January 2017 - 19:34 PM

Hi my riends... my little add to this forum: DELETE_FILE not working on server. 

 

I got a 404 not found error when deleting uploaded files.... but ONLY and so ONLY when deleting jpg jpeg and png ...

 

 

after two month crazy.... with a server side master of programming we found that on NGNX linux you must touch on the config file this line of code..... any expert will know what to with this information...... 

 

location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }

any who knows what im talking abaut pls feel free to complete this issue.

 

 

the thing is to ad a # to location lines

 

location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }

 

 

good luck and

Thanks to all !!!


Isra
  • profile picture
  • Member

Posted 19 November 2018 - 02:50 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. Thanks buddy

 

 



 

....

and I also have 
$config['index_page'] = 'index.php';
 
in my config.php