Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

alendre

na função de Download...

Recommended Posts

E aí galera... beleza...

 

Olha só peguei esta função aqui no forum ela funciona muito bem aqui no meu pc, mas quando eu coloco no ar dá erro...

 

<?php require_once('../../Connections/ConnPetImagem.php'); ?><?php$colname_rsD = "-1";if (isset($_GET['arq_id'])) {  $colname_rsD = (get_magic_quotes_gpc()) ? $_GET['arq_id'] : addslashes($_GET['arq_id']);}mysql_select_db($database_ConnPetImagem, $ConnPetImagem);$query_rsD = sprintf("SELECT * FROM arquivos WHERE arq_id = %s", $colname_rsD);$rsD = mysql_query($query_rsD, $ConnPetImagem) or die(mysql_error());$row_rsD = mysql_fetch_assoc($rsD);$totalRows_rsD = mysql_num_rows($rsD);$file = $row_rsD['arq_doc'];function dwfile($file) { 	if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) 	{ 		// IE Bug in download name workaround 		ini_set( 'zlib.output_compression','Off' ); 	} 	header ('Content-type: ' . mime_content_type($file)); // LINHA Q DÁ O ERRO	header ('Content-Disposition: attachment; filename="'.basename($file).'"'); 	header ('Expires: '.gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y"))).' GMT'); 	header ('Accept-Ranges: bytes'); 	header ('Cache-control: no-cache, must-revalidate'); 	header ('Pragma: private'); 	$size = filesize($file); 	if(isset($_SERVER['HTTP_RANGE'])) 	{ 		list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']); 		//if yes, download missing part 		str_replace($range, "-", $range); 		$size2=$size-1; 		$new_length=$size2-$range; 		header("HTTP/1.1 206 Partial Content"); 		header("Content-Length: $new_length"); 		header("Content-Range: bytes $range$size2/$size"); 	} 	else 	{ 		$size2=$size-1; 		header("Content-Range: bytes 0-$size2/$size"); 		header("Content-Length: ".$size); 	} 	if ($file = fopen($file, 'rb')) 	{ 		while(!feof($file) and (connection_status()==0)) 		{ 			print(fread($file, 1024*8)); 			flush(); 		} 		$status = (connection_status()==0); 		fclose($file); 	} 	return($status); } dwfile($file); mysql_free_result($rsD);?>

A função aqui em cima já está com o meu acesso ao BD, ok...

 

E quando eu tento acessá-la no Site acontece esse erro:

 

Fatal error: Call to undefined function: mime_content_type() in /htdocs/home/petimagem/www/artigos/arquivos/download.php on line 21

 

Galerinha por favor me ajudem... Se o cliente me dá a carta de demissão...

 

Desde já agradeço a atenção de todos...

 

Abraços...

Compartilhar este post


Link para o post
Compartilhar em outros sites

eu coloco assim .. comigo funciona na boa... não sei se é o correto...mas é oque eu uso...header("Content-type: application/nome_da_extenção");para pegar o nome da extenção eu dou um explode no explode('.',$file['name']) não sei se funciona o $file['type']...Testa ai se funcionar posta aqui se não funcionar posta tambem... hehet+

Compartilhar este post


Link para o post
Compartilhar em outros sites

Opa... E aí galera... beleza...

 

Bom eu tinha pedido ajuda pra função download, pega aqui mesmo no forum, e o rsddaros tentou me ajudar indicando a função explode pra retirar a extensão do arquivo...

 

Ajudou bastante...

 

Valw daros...

 

Mas o problema persistiu...

 

Daí numa das muitas tentativas usei as funções end() e explode() juntas resolvendo o meu problema...

 

Isto é, pra quem tá chegando agora e pegou o trem andando: estava dando pau a função mime_content_type() informando esse erro:

 

Fatal error: Call to undefined function: mime_content_type() in /htdocs/home/petimagem/www/artigos/arquivos/download.php on line 21...

 

Ok...

 

Eis o código com a resolução do problema:

 

Dentro da função coloquei:

 

$ext = end(explode('.', $file));

 

header ('Content-type: application/'. $ext);

 

$file	= " Caminho do Arquivo ";function dwfile($file) { 	if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) 	{ 		// IE Bug in download name workaround 		ini_set( 'zlib.output_compression','Off' ); 	}// Aqui a parte que dava pau:// header ('Content-type:'. mime_content_type($file));// Substituindo por essa:	$ext = end(explode('.', $file));	header ('Content-type: application/'. $ext);	header ('Content-Disposition: attachment; filename='. basename($file)); 	header ('Expires: '.gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y"))).' GMT'); 	header ('Accept-Ranges: bytes'); 	header ('Cache-control: no-cache, must-revalidate'); 	header ('Pragma: private'); 	$size = filesize($file); 	if(isset($_SERVER['HTTP_RANGE'])) 	{ 		list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']); 		//if yes, download missing part 		str_replace($range, "-", $range); 		$size2=$size-1; 		$new_length=$size2-$range; 		header("HTTP/1.1 206 Partial Content"); 		header("Content-Length: $new_length"); 		header("Content-Range: bytes $range$size2/$size"); 	} 	else 	{ 		$size2=$size-1; 		header("Content-Range: bytes 0-$size2/$size"); 		header("Content-Length: ".$size); 	} 	if ($file = fopen($file, 'rb')) 	{ 		while(!feof($file) and (connection_status()==0)) 		{ 			print(fread($file, 1024*8)); 			flush(); 		} 		$status = (connection_status()==0); 		fclose($file); 	} 	return($status); } dwfile($file);

 

Aí galera valw pela ajuda...

 

Quem quiser dar uma olhada é só clickar:Site

 

T+

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.