note 121148 deleted from function.fgetcsv by cmb

From: Date: Sun, 16 Jun 2019 08:16:04 +0000
Subject: note 121148 deleted from function.fgetcsv by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211275@lists.php.net to get a copy of this message
Note Submitter: hello at fxstar dot eu ---- Import contacts from uploaded file: <? if (isset($_POST['add'])) { set_time_limit(3600); error_reporting(0); echo '<p class="etop"> Importuję kontakty ... zaczekaj może to potrwać chwilę!</p>'; $grid = (int)$_POST['groupid']; // from upload file $csv = $_FILES['file']['tmp_name']; $csvname = $_FILES['file']['name']; $imp = 0; $row = 1; if (pathinfo(basename($csvname),PATHINFO_EXTENSION) == 'csv') { if (($handle = fopen($csv, "r")) !== FALSE) { fgetcsv($handle); while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { /// function with explode line and add to database // return 1 - added, 0 - dont $count = AddKontaktCSV($row[0], $grid); // echo $row[0]; // ile kontaktów sie zaimportowało $imp = $imp + $count; } fclose($handle); $error1 = 'Zaimportowano '.$imp.' kontakty(ów)!'; }else{ $error1 = "Error csv"; } }else{ $error1 = "Tylko pliki .csv"; } // delete file unlink($csv); } ?> <form method="POST" action="" enctype="multipart/form-data"> <p class="formerror"><?php echo $error1; ?></p> <label>Nazwa grupy <span>*</span></label> <select name="groupid"> <option value="123">Grupa 123</option> <option value="999">Grupa 999</option> </select> <label>Plik csv (max. 100 000 kontaktów w pliku)*</label> <input type="file" name="file"> <p style="font-size: 13px;"> * - pola wymagane <a href="import_kontaktow.csv" style="float: right; color: #393; font-weight: bold;"> Przykładowy plik .csv</a> </p> <input type="submit" name="add" value="Wyślij plik .csv" class="btn"> </form>

« previous php.notes (#211275) next »