Tuesday, May 22, 2012

Get new and modified files from n days ago

This is another way to get new and modified files from your project.

If you use cvs system, you need to export files first

(using svn)*
svn export files/path export/path

* Maybe you need to use before
svn add * --force

Go to export/path and get the last new/modified files you want
cd export/path
find . -mtime -N -ctime -N | cpio -vdump ../final_files


N are the days that you want to get, so if you need to get files from 7 days ago then you write:
find . -mtime -7 -ctime -7 | cpio -vdump ../final_files

Monday, May 07, 2012

Codeigniter: multifile_array upload helper

If you need to use multiple files for upload in a form, but using array names (like files[]) with Codeigniter is not possible. Besides, $_FILES schema is not compatible with $this->upload->do_upload().
With this helper you can use this kind of names for make it possible. Only use array name for all files in a form and use the helper:

In view
<form...
<input type="file" name="f_file[]">
<input type="file" name="f_file[]">
...
</form>

In controller
$this->load->helper('upload');
multifile_array();
foreach ($_FILES as $file => $file_data)
  $this->upload->do_upload($file);

Download multifile_array upload helper