php sistem çağrısı kullanılarak onay kutusu seçimini göre dosyaları birleştirmek için nasıl

1 Cevap php

Ben, ben checkboxes.if bir onay kutusu seçimi temelinde birleştirmek için php bazı dosyalar ihtiyaç var ihtiyacına ve bu yüzden sistem çağrısı kullanılarak yapmak zorunda on.This göre CONCATENATE seçilir, ve ben (php ve ssh çalışıyorum güvenli kabuk istemci)

1 Cevap

Eğer gibi HTML ile, bir diziye dosyaları olsun varsayarsak

<?php
$files = array('file1.txt', 'file2.txt', 'file3.txt'); 
?>
<form action="action.php" method="post">
   <?php foreach ($files as $k => $files) { ?>
      <input type="checkbox" name="files[<?php echo $k;?>]" value="<?=$k;?>" />
   <?php } ?>
   <input type="submit" name="submit" value="ok" />
</form>

Sen erişebilirsiniz php ile checkboxed kontrol

<?php
    //I've made assumption outfile is in same path as source files
    $path = '/var/www/whatever/to/files/';
    $dest_file = $path . 'out.txt';
    //create empty file if not exists
    passshtru("touch $dest_file;");
    foreach ($_POST['files'] as $key) {
      $source_file = $path . $files[$key];
      //co contactenation using shell redirect
      passthru("cat $source_file >> $dest_file;");
    }

    //do whatever you want with generated file in /var/www/whatever/to/files/out.txt

You could need to put real path to binaries touch and cat, depending on your system config. I'm curious to know where is the need to do this with system calls, is theses files big ?