• Resolved itofficer16mm

    (@itofficer16mm)


    I’m really appreciating this plugin, but noticed that the uploaded CSVs are remaining in wp-content/uploads/2019/08 (and publicly downloadable).

    I’m uploading within wp-admin, rather than via the front-end or cron or whatever.

    Obviously I can go through and remove the files, but would have thought this was something the plugin should do?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Javier Carazo

    (@carazo)

    Good morning @itofficer16mm,

    Plugin removes automatically files after being processed. This is a basic security feature.

    If this is not working in this way, it can be that the process is being broken before finishing, or maybe some kind of limitation in your system that avoid deleting the files by the plugin.

    Thread Starter itofficer16mm

    (@itofficer16mm)

    Hi,

    Thanks for that. I’m definitely able to delete media files generally on the site. Poking around a bit, it looks like acui_get_attachment_id_by_url() is returning nothing – haven’t dug into that further yet – and so acui_import_users() doesn’t have an attachment ID to delete.

    Best wishes,

    Richard

    Plugin Author Javier Carazo

    (@carazo)

    Thanks! So we have:

    function acui_get_attachment_id_by_url( $url ) {
    	$wp_upload_dir = wp_upload_dir();
    	// Strip out protocols, so it doesn't fail because searching for http: in https: dir.
    	$dir = set_url_scheme( trailingslashit( $wp_upload_dir['baseurl'] ), 'relative' );
    
    	// Is URL in uploads directory?
    	if ( false !== strpos( $url, $dir ) ) {
    
    		$file = basename( $url );
    
    		$query_args = array(
    			'post_type'   => 'attachment',
    			'post_status' => 'inherit',
    			'fields'      => 'ids',
    			'meta_query'  => array(
    				array(
    					'key'     => '_wp_attachment_metadata',
    					'compare' => 'LIKE',
    					'value'   => $file,
    				),
    			),
    		);
    
    		$query = new WP_Query( $query_args );
    
    		if ( $query->have_posts() ) {
    			foreach ( $query->posts as $attachment_id ) {
    				$meta          = wp_get_attachment_metadata( $attachment_id );
    				$original_file = basename( $meta['file'] );
    				$cropped_files = wp_list_pluck( $meta['sizes'], 'file' );
    
    				if ( $original_file === $file || in_array( $file, $cropped_files ) ) {
    					return (int) $attachment_id;
    				}
    			}
    		}
    	}
    
    	return false;
    }
    

    Have you changed your uploads url?

    Thread Starter itofficer16mm

    (@itofficer16mm)

    Sorry for delay getting back to you – been totally overwhelmed with the paid work, and family health stuff.

    No, I’ve not changed the uploads URL; the URL being passed to acui_get_attachment_id_by_url is of the form https://<domain>/wp-content/uploads/2019/09/<filename.csv&gt;

    I’m not seeing a wp_post or any wp_postmeta for the attachment – it’s like it’s being saved into wp_content/uploads but not saved as an attachment in the database.

    Plugin Author Javier Carazo

    (@carazo)

    @itofficer16mm,

    Attachment is created in your case maybe this is deleted (the post entry) but not the file.

    It can be some kind of permission problem.

    It is working in thousend of site without incidents… so it has to be created by your site in some way.

    Thread Starter itofficer16mm

    (@itofficer16mm)

    I’m sorry, I’ve tried now on three entirely different hosting environments (different PHP versions, different HTTP server software, different OS), and seeing consistent results ??

    Also just installed Query Monitor to see what queries are hitting the database, and nothing is being inserted in wp_posts or wp_postmeta. I’m seeing the query where acui_get_attachment_id_by_url() tries to find the attachment ID, but nothing previous to that inserting it.

    Plugin Author Javier Carazo

    (@carazo)

    I have tried again and it works like always (correctly deleting file after importing it).

    Which version are you using? Are you using the last one? I could see what’s happening in your site but it would be a “premium” support.

    Thread Starter itofficer16mm

    (@itofficer16mm)

    I’m using 1.14.3.2, on WP 5.2.3.

    Plugin Author Javier Carazo

    (@carazo)

    This is OK. I cannot check more from here, if you want personal support, tell us.

    Hello,

    Browsing through support for another problem, I see this and check my upload folder and .csv files for the plugin are also still there.

    Last version of WP, last version of plugin. I can delete attachement without problem via the Media menu.

    The /wp-content/uploads/2019 permissions are 705

    Regards,

    Plugin Author Javier Carazo

    (@carazo)

    @aralici,

    Good afternoon, after finish the process, plugin delete the CSV that has been uploaded.

    Is the execution being finished?

    Hi Javier,

    Yes, the site is brand new (a week), I uploaded a dozen csv files to creates 6500 users and update their meta and all worked well.

    I look at the uploads folder only today because of this thread and find all of the files untouched.

    Best regard,
    aral.ici

    Plugin Author Javier Carazo

    (@carazo)

    This is really strage, it works in all our test sites.

    We could see in your site, but it would be personal support.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Uploaded CSV file remains in wp-content/uploads’ is closed to new replies.