cablop.net – Software Tips

Tips de software, hardware… y algo más

Skip to: Content | Sidebar | Footer

Warning: URL file-access is disabled in the server configuration

29 Agosto, 2009 (11:44) | PHP | By: 天龙

Este caso se me presentó con un línea del siguiente estilo:

$response=file_get_contents("http://web.com/contenido.xml");

Y no se podía solucionar con el archivo php.ini ni con la variable allow_url_fopen = On ni con allow_url_include = On.

Entonces, ¿cómo se soluciona?

Sí se tiene cURL en el servidor pues lo podemos solucionar de la siguiente manera:

$fileURL = "http://pagina.web/.../archivo";
$ch = curl_init($fileURL);
$file = "/ruta/a/temporales/temporal" . time();
$fp = @fopen($file, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$response = file_get_contents($file);
unlink($file);

Naturalmente tenemos que contar con que cURL esté correctamente configurado y que tengamos permiso de escritura del archivo “temporal” (o el nombre que le hayamos querido dar).

Write a comment





To submit your comment, click the image below where it asks you to... Clickcha - The One-click Captcha