Skip to content
Todo se AprendeAyuda y trucos para programación
  • Home
  • Categorías
    • Debian
    • JS
    • PHP
    • WordPress
    • MySql
    • Cordova

Acceder a / Crear unidad de red desde PHP

15/10/2019 0 comments Article PHP

Como acceder / crear una unidad de red desde PHP

function crear_unidad_red($letter){
		$location = "\\\\ip_servidor\\carpeta\\subcarpeta\\etc...";
	    $user = "nombre_de_usuario";
	    $pass = "contraseña";

		if(!is_dir("$letter:")):
			// Map the drive
	    	system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no ");
		endif;

		// Borrar unidad
		// system("net use $letter: /delete /y");
	}

	$unidad = 'Z';
	crear_unidad_red($unidad);

	// The location of the PDF file on the server.
	$filename = "$unidad:\\nombre_del_archivo.pdf";

	if(file_exists($filename)):
		// Let the browser know that a PDF file is coming.
		header("Content-type: application/pdf");
		header('Content-Disposition: inline; filename="nombre_del_archivo.pdf"');
		header("Content-Length:".filesize($filename));

		// Send the file to the browser.
		readfile($filename);
	else:
		echo 'No existe el fichero';
	endif;
0 0 votes
Article Rating
Tags: Map the drive, net use, persistent, php, system, unidad de red
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments

Entradas recientes

  • Bash mysql dump database
  • Minificar CSS y Javascript con PHP
  • Tabla SQL población España
  • Validar DNI (NIF), CIF, NIE
  • Table tr collapsible Jquery

Categorías

  • Cordova
  • Debian
  • JS
  • MySql
  • PHP
  • Sin categoría
  • WordPress

Archivos

Copyright Todo se Aprende 2022 | Theme by ThemeinProgress | Proudly powered by WordPress

wpDiscuz
Utilizamos cookies para asegurar que damos la mejor experiencia al usuario en nuestro sitio web. Si continúa utilizando este sitio asumiremos que está de acuerdo.Estoy de acuerdoLeer más