Acceder a / Crear unidad de red desde 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;

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Captcha cargando...