Jump to content


set_upload_field can't delete files

set_upload_field delete

  • Please log in to reply
13 replies to this topic

#1 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

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!



#2 tlc033

tlc033

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationChisinau

Posted 18 March 2013 - 02: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.


We are a web company from Republic of Moldova and offers services as, web design, web development, eCommerce, online marketing and advertising, consulting and web optimization, search engine optimization (SEO) and social media optimization (SMO), branding and rebranding.

 

          logo_small.png  

                         elitiv.com  

                  

 

 


#3 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

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..



#4 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

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:800..._=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?



#5 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 March 2013 - 03: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:800..._=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?



#6 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 19 March 2013 - 06:36 PM

Hello and welcome to the forums.

Which version of Grocery CRUD have you downloaded?


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#7 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 March 2013 - 07: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");
                    }
                });


#8 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 March 2013 - 09: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"}



#9 yourself

yourself

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 March 2013 - 09: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


#10 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 21 December 2016 - 07:11 PM

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



#11 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 22 December 2016 - 06: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!!



#12 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 22 December 2016 - 06: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!!



#13 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 21 January 2017 - 07: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 !!!



#14 Isra

Isra

    Newbie

  • Members
  • Pip
  • 2 posts

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

 







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users