Johny Posted November 9, 2009 at 04:55 PM Report Share #295274 Posted November 9, 2009 at 04:55 PM Boa tarde pessoal, Estou agora a tentar enviar um ficheiro pdf via web em que o ficheiro está alojado na pasta PDF e o email para enviar ele vai buscar através de variavel. So que esta me a dar este erro 😉 Warning: fopen(/PDF/testes_1-01-2009.pdf) [function.fopen]: failed to open stream: No such file or directory in Warning: fread(): supplied argument is not a valid stream resource in Warning: fclose(): supplied argument is not a valid stream resource in deixo aqui o código também para ver se descobrem onde esta o erro $attach = "/PDF/$ficheiro.pdf"; $mailheaders = "From: $from\n"; $mailheaders .= "Reply-To: $from\n"; $mailheaders .= "Cc: $cc\n"; $mailheaders .= "Bcc: $bcc\n"; $mailheaders .= "X-Mailer: Script para enviar arquivo atachado\n"; $msg_body = stripslashes($body); if ($attach != "none") { $file = fopen($attach, "r"); $contents = fread($file, $attach_size); $encoded_attach = chunk_split(base64_encode($contents)); fclose($file); $mailheaders .= "MIME-version: 1.0\n"; $mailheaders .= "Content-type: multipart/mixed; "; $mailheaders .= "boundary=\"Message-Boundary\"\n"; $mailheaders .= "Content-transfer-encoding: 7BIT\n"; $mailheaders .= "X-attachments: $attach_name"; $body_top = "--Message-Boundary\n"; $body_top .= "Content-type: text/plain; charset=US-ASCII\n"; $body_top .= "Content-transfer-encoding: 7BIT\n"; $body_top .= "Content-description: Mail message body\n\n"; $msg_body = $body_top . $msg_body; $msg_body .= "\n\n--Message-Boundary\n"; $msg_body .= "Content-type: $attach_type; name=\"$attach_name\"\n"; $msg_body .= "Content-Transfer-Encoding: BASE64\n"; $msg_body .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n"; $msg_body .= "$encoded_attach\n"; $msg_body .= "--Message-Boundary--\n"; } mail($to, stripslashes($subject), $msg_body, $mailheaders); Cumprimentos 🙂 APARTE: Usa o Geshi, torna o código mais apresentável. 🙂 ############# Link to comment Share on other sites More sharing options...
infopc Posted November 10, 2009 at 02:15 AM Report Share #295365 Posted November 10, 2009 at 02:15 AM Só uma pergunta a pasta PDF esta na raiz do teu servidor? é que $attach = "/PDF/$ficheiro.pdf"; quer dizer isso mesmo. O que não tem solução, solucionado esta... Link to comment Share on other sites More sharing options...
Johny Posted November 10, 2009 at 10:07 PM Author Report Share #295500 Posted November 10, 2009 at 10:07 PM Ola de novo hoje perdi mais um bocado de tempo e já resolvi todos os problemas já funciona correctamente obrigado a mesma =) Cumprimentos, ############# Link to comment Share on other sites More sharing options...
salvador069 Posted March 5, 2012 at 12:00 AM Report Share #442267 Posted March 5, 2012 at 12:00 AM boas seria possivel deixares aqui como resolveste o teu problema cumprimentos Link to comment Share on other sites More sharing options...
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