infopc Posted August 7, 2009 at 01:21 PM Report #282511 Posted August 7, 2009 at 01:21 PM Boas Estou a fazer um sistema de download tipo rapidashare, até agora tenho o seguinte: Gero link encriptado com o caminho para o ficheiro tenho uma class que desincripta o link e procura o ficheiro a questão agora é: como faço para o download se iniciar sem o utilizador ver o link? a pagina que gere os links é: http://www.exemplo.com/ajax/files/get_file/62//llh599.%5Chaflg4/ge_:fk4gj-9e_:a~9vg.T4:g.p //previamente carreguei o url completo para $uri $file = str_replace('http://www.exemplo.com/files/get_file/62/', '', $uri); url_decrypt($file); //neste momento eu já sei que o ficheiro é "http://www.exemplo.com/ficheiros/teste.rar" //quero agora iniciar o download sem reencaminhar para o link em questão Obrigado O que não tem solução, solucionado esta...
softklin Posted August 7, 2009 at 01:34 PM Report #282513 Posted August 7, 2009 at 01:34 PM Talvez um file_get_contents: http://pt2.php.net/manual/en/function.file-get-contents.php e depois despejas o conteúdo do ficheiro no browser, com os heads de download adequados (pdf, se for um pdf, etc.). Convém é que esteja no mesmo host. Nick antigo: softclean | Tens um projeto? | Wiki P@P Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post.
infopc Posted August 7, 2009 at 01:54 PM Author Report #282515 Posted August 7, 2009 at 01:54 PM já encontrei solução, mas obrigado a mesma, esta a esquecer-me da função flush(); deixo aqui a minha solução. //previamente carreguei o url completo para $uri $file = str_replace('http://www.exemplo.com/files/get_file/62/', '', $uri); url_decrypt($file); //gero array que tem a informação do ficheiro $inf = get_file_info($file); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: ".$inf['mime']); header("Content-Disposition: attachment; filename=\"".$inf['name']."\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $inf['size']); $file = @fopen($inf['server_path'],"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } O que não tem solução, solucionado esta...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now