$fich_dest = fopen($path_dest, "w"); $fich_htaccess = fopen($temp_dir . ".htaccess", "w"); if ($fich_orig && $fich_dest && $fich_htaccess) { // Print header fwrite($fich_dest, Ubicacion::printHeader() . "\n"); // Skip first line fgets($fich_orig); while (($line = fgets($fich_orig)) !== false) { // Process the line read $id_elem = generateID(); $datos = explode(",", $line); $lat = $datos[2]; $long = $datos[3]; $ubic = new Ubicacion($id_elem, $lat, $long); $file_name = str_replace(".txt", "", $nombre); fwrite($fich_dest, $ubic->__toString() . "\"" . PHP_EOL); } fclose($fich_orig); unlink($path_orig); fclose($fich_dest); fwrite($fich_htaccess, "Options +Indexes"); fclose($fich_htaccess); } } } } } // GENERATEID: Generate ID function generateID($length = 32) { $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$file_selected = array_key_exists("fileToUpload", $_FILES); } if ($file_selected && ($fd_convertido = fopen($destination_file, "w"))) { if ($fd_original = fopen($original_file, "r")) { fwrite($fd_convertido, Ubicacion::printHeader() . "\n"); // Skip first line fgets($fd_original); while (($line = fgets($fd_original)) !== false) { // process the line read. $id_elem = generarID(); $datos = explode(",", $line); $lat = $datos[2]; $long = $datos[3]; $ubic = new Ubicacion($id_elem, $lat, $long); $file_name = str_replace(".txt", "", $file_name); fwrite($fd_convertido, $ubic->__toString() . ", \"" . $file_name . "\"" . ", \"" . $file_name . "_" . $id_elem . "\"" . PHP_EOL); } fclose($fd_original); } fclose($fd_convertido); } else { // error opening the file. echo "Lo sentimos, se ha producido un error al abrir el archivo.<br><br>"; } if (strpos($original_file, "_") != 0) { unlink($original_file); } } function generarID($length = 32) { $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';