UPDATED URLs
Hi, I want to download an external file and replace some characters and save the data in a file on my server.
Here shows how it does, what I want to do is using cUrl, since the new hosting provider does not allow me to use these functions here, but what if.
<?php
$file = file("http://exabytetv.info/sgeo.m3u");
// Reemplazando
$bodytag = str_replace(' url-tvg="atv"', "",$file);
$cadena_equipo = implode("", $bodytag);
$file = 'lista.m3u';
$current = file_get_contents($file);
$current = $cadena_equipo;
file_put_contents($file, $current);
?>
Here I download a file, but it does not change.
<?php
ob_start();
$url = "http://exabytetv.info/sgeo.m3u";
//El nombre del archivo donde se almacenara los datos descargados.
$filePath = @fopen("lista.m3u", "w");
//Inicializa Curl.
$ch = curl_init();
//Pasamos la url a donde debe ir.
curl_setopt($ch, CURLOPT_URL, $bodytag);
//Si necesitamos el header del archivo, en este caso no.
curl_setopt($ch, CURLOPT_HEADER, false);
//Si necesitamos descargar el archivo.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Lee el header y se mueve a la siguiente localización.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//Cantidad de segundo de limite para conectarse.
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
//Cantidad de segundos de limite para ejecutar curl. 0 significa indefinido.
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
//Donde almacenaremos el archivo.
curl_setopt($ch, CURLOPT_FILE, $filePath);
//curl_exec ejecuta el script.
$result = curl_exec($ch);
//Dejamos de utilizar el archivo creado.
fclose($fd);
if($result){ //funciono ?
echo "Descarga correcta.";
// header('Location: convertir-local.php');
}
?>
I want to download external file, read it, replace some characters and save it. Thank you in advance.