Forums

How to automatically delete files?

sillesco 06 Feb, 2014
Hello

I have an option to upload files on my form, but I just need the files are sent to email, and files must be sent to the hosting.

Then I read this FAQ for automatic deletion.

http://www.chronoengine.com/faqs/53-cfv4/cfv4-file-uploads/2665-how-can-i-delete-old-file-uploads.html

But it does not work. What I fail?

thanks


[attachment=0]Sin título 1.png[/attachment]


[attachment=1]Sin título 2.png[/attachment]
GreyHead 06 Feb, 2014
Hi sillesco,

The obvious problem is that, as far as I can see, $files isn't defined in your code.

Bob
sillesco 07 Feb, 2014
Excuse me, I do not understand well. How do I set the file?

Do I have to write the path? Where in?
GreyHead 07 Feb, 2014
Hi sillesco,

Please check the FAQ again, that includes the code to define $files.

Bob
sillesco 07 Feb, 2014
Sorry, I dont speak english

Not work

Mi code:

<?php
$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/Enviaraaporte*');
$checktime = time() - 0 * 00 * 00 * 02;
foreach ( $files as $v ) {
  if ( is_file($v) && filemtime($v) < $checktime ) {
    unlink($v);
  }
}
?>


I try

<?php
$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/*');
$checktime = time() - 0 * 00 * 00 * 02;
foreach ( $files as $v ) {
  if ( is_file($v) && filemtime($v) < $checktime ) {
    unlink($v);
  }
}
?>


But the same results

PD: "Enviaraaporte" is my name form
GreyHead 08 Feb, 2014
Hi sillesco,

This line
$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/Enviaraaporte*');
is missing a /
$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/Enviaraaporte/*');
if that doesn't fix it then you need to add some debugging PHP to see exactly what is happening.

Bob

PS Note that time() - 0 * 00 * 00 * 02; is exactly the same as time();
sillesco 08 Feb, 2014
Hi bob


This is my debug


Data Array: 
Array
(
    [chronoform] => Enviaraaporte
    [event] => submit
    [input_textarea_11] => asad
    [input_textarea_10] => asd
    [input_select_4] => No
    [input_select_14] => si
    [input_textarea_2] => 
    [input_textarea_13] => ccc
    [input_textarea_12] => vbbv
    [input_checkbox_7] => 1
    [file_upload_1] => 20140208155727_7991_580420545373814_322902944_n.jpg
    [input_submit_6] => Enviar aportación
    [417c525947b6cf0ff78f50fffb590e95] => 1
    [_PLUGINS_] => Array
        (
            [upload_files] => Array
                (
                    [file_upload_1] => Array
                        (
                            [name] => 20140208155727_7991_580420545373814_322902944_n.jpg
                            [original_name] => 7991_580420545373814_322902944_n.jpg
                            [path] => /home/MINOMBREUSUARIO/public_html/components/com_chronoforms/uploads/Enviaraaporte/20140208155727_7991_580420545373814_322902944_n.jpg
                            [size] => 55392
                            [link] => http://www.miweb.es/components/com_chronoforms/uploads/Enviaraaporte/20140208155727_7991_580420545373814_322902944_n.jpg
                        )

                )

        )

    [user_id] => 836
)
Validation Errors: 
Array
(
)
¡Gracias por enviar tu aportación! Debug Data
Upload routine started for file upload by : file_upload_1
/home/MINOMBREUSUARIO/public_html/components/com_chronoforms/uploads/Enviaraaporte/20140208155727_7991_580420545373814_322902944_n.jpg has been uploaded successfully.
email
8
Result
An email has been SENT successfully from (Mi dominio)MICRREO@MIOTROCORREO.es to MICRREO@MIOTROCORREO.es
Body
Título *	 asad
Etiquetas (separadas por comas) *	 asd
¿Eres tú quien aparece en la fotografía o gif? *	 No
Sección *	 si
Nota	
Nombre de usuario *	 ccc
Correo electrónico con el que te registraste *	 vbbv
Aceptas las condiciones de colaboración *	 1
Imagen/gif *	 20140208155727_7991_580420545373814_322902944_n.jpg


Submitted by MI IP
Consola de Joomla! Debug
Sesión
Información de Perfil
Uso de Memoria
Registro Database
Attachments
array ( 0 => '/home/MINOMBRUESUARIO/public_html/components/com_chronoforms/uploads/Enviaraaporte/20140208155727_7991_580420545373814_322902944_n.jpg', )
GreyHead 09 Feb, 2014
Hi sillesco,

Thank you but that tells us nothing about your custom code - you need to debug that to see what is (or isn't) happening.

Bob
sillesco 12 Feb, 2014
's settled, it was like you said. Thank you very much
This topic is locked and no more replies can be posted.