Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z przesłaniem załącznika
Forum PHP.pl > Forum > PHP
bubolski
Oto pliczek. W pogrubionej linijce wywala błąd zeby okreslic nazwe pliku czy cos takiego.

Kod
<?php
include "../res/imemail.inc.php";

//Form Data
$txtData = "";
$htmData = "";
$txtData .= "Podaj swój adres e-mail: " . $_POST["Itm_8_00_1"] . "\r\n";
$htmData .= "<tr><td width=\"25%\"><b>Podaj swój adres e-mail:</b></td><td>" . $_POST["Itm_8_00_1"] . "</td></tr>";
$txtData .= "Krótki opis: " . $_POST["Itm_8_00_2"] . "\r\n";
$htmData .= "<tr><td width=\"25%\" bgcolor=\"#EEEEEE\"><b>Krótki opis:</b></td><td bgcolor=\"#EEEEEE\">" . $_POST["Itm_8_00_2"] . "</td></tr>";
$txtData .= "Załącznik: " . $_FILES["Itm_8_00_3"]["name"] . "\r\n";
$htmData .= "<tr><td width=\"25%\"><b>Załącznik:</b></td><td>" . $_FILES["Itm_8_00_3"]["name"] . "</td></tr>";

// Template
$htmHead = "<table width=\"90%\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"4\" style=\"font: 11px Tahoma; color: #000000; border: 1px solid #BBBBBB;\">";
$htmFoot = "</table>";

//Send email to owner
$txtMsg = "";
$htmMsg = $htmHead . "<tr><td></td></tr>" . $htmFoot;
$oEmail = new imEMail(($imForceSender ? $_POST["Itm_8_00_1"] : "cv@job-less.com.pl"),"cv@job-less.com.pl","CV","windows-1250");
$oEmail->setText($txtMsg . "\r\n\r\n" . $txtData);
$oEmail->setHTML("<html><body bgcolor=\"#063A69\"><center>" . $htmMsg . "<br>" . $htmHead . $htmData . $htmFoot . "</center></body></html>");
[b]if ($_FILES["Itm_8_00_3"]["name"] != "") $oEmail->attachFile($_FILES["Itm_8_00_file_get_contents($_FILES["Itm_8_00_3"]["name"]),3"]["name"],$_FILES["Itm_8_00_3"]["type"]);
$oEmail->send();[/b]

//Send email to user
$txtMsg = "Dziękujemy za przesłanie aplikacji i podjęcie współpracy z naszą firma.";
$htmMsg = $htmHead . "<tr><td>Dziękujemy za przesłanie aplikacji i podjęcie współpracy z naszą firma.</td></tr>" . $htmFoot;
$oEmail = new imEMail("cv@job-less.com.pl",$_POST["Itm_8_00_1"],"Touch Media S.A.","windows-1250");
$oEmail->setText($txtMsg);
$oEmail->setHTML("<html><body bgcolor=\"#063A69\"><center>" . $htmMsg . "</center></body></html>");
$oEmail->send();
@header("Location: ../zaplac.html");
?>

wookieb
No bo co to za dziwny klucz w tablicy $_FILES? Na 100% nie masz takiego.
bubolski
Nie specjalnie mi to duzo mowi , poniewaz wysylanie maila z zalacznikiem , jest wygenerowane przez program website x 5 Evo.

do wysylania mail sa tylko 2 pliki podany wyzej i ten :
Kod
<?php
  //Incomedia WebSite X5 EMail Class. All rights reserved.

    //true = force the user email address to be set as the sender
  $imForceSender = false;
  
    class imEMail {
        var $from;
        var $to;
        var $subject;
        var $charset;
        var $text;
        var $html;
        
        var $attachments;
        
        function imEMail($from,$to,$subject,$charset) {
            $this->from = $from;
            $this->to = $to;
            $this->subject = $subject;
            $this->charset = $charset;
        }
        
        function setFrom($from) {
            $this->from = $from;
        }
        
        function setTo($to) {
            $this->to = $to;
        }
        
        function setSubject($subject) {
            $this->subject = $subject;
        }
        
        function setCharset($charset) {
            $this->charset = $charset;
        }
        
        function setText($text) {
            $this->text = $text;
        }
        
        function setHTML($html) {
            $this->html = $html;
        }
        
        function attachFile($name,$content,$mime_type) {
            $attachment['name'] = $name;
            $attachment['content'] = base64_encode($content);
            $attachment['mime_type'] = $mime_type;
            $this->attachments[] = $attachment;
        }
        
        function send() {
            $headers = "";
            $msg = "";

            if($this->from == "" || $this->to == "" || ($this->text == "" && $this->html == ""))
                return false;
            
            $boundary = md5(time());
            
            $headers .= "From: " . $this->from . "\r\n";
            $headers .= "Message-ID: <" . time() . rand(0,9) . rand(0,9) . "@websitex5.users>\r\n";
            $headers .= "X-Mailer: WebSiteX5 Mailer\r\n";
            $headers .= "MIME-Version: 1.0\r\n";

            if(is_array($this->attachments)) {
                $headers .= "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"\r\n\r\n";
                $headers .= "--" . $boundary . "\r\n";
            }
            
            if($this->html == "") {
                $headers .= "Content-Type: text/plain; charset=" . $this->charset . "\r\n";
                $headers .= "Content-Transfer-Encoding: 8bit\r\n";
                $msg .= $this->text . "\r\n\r\n";
            }
            else if($this->text == "") {
                $headers .= "Content-Type: text/html; charset=" . $this->charset . "\r\n";
                $headers .= "Content-Transfer-Encoding: 8bit\r\n";
                $msg .= $this->html . "\r\n\r\n";
            }
            else {
                $alt_boundary = $boundary . "_alt";
                $headers .= "Content-Type: multipart/alternative; boundary=\"" . $alt_boundary . "\"\r\n";
                
                $msg .= "--" . $alt_boundary . "\r\n";
                $msg .= "Content-Type: text/plain; charset=" . $this->charset . "\r\n";
                $msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $msg .= $this->text . "\r\n\r\n";
                
                $msg .= "--" . $alt_boundary . "\r\n";
              $msg .= "Content-Type: text/html; charset=" . $this->charset . "\r\n";
                $msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $msg .= $this->html . "\r\n\r\n";
                
                $msg .= "--" . $alt_boundary . "--\r\n\r\n";
            }
            
            if(is_array($this->attachments)) {
                foreach($this->attachments as $attachment) {
                    $msg .= "--" . $boundary . "\r\n";
                    $msg .= "Content-Type: " . $attachment["mime_type"] . "; name=\"" . $attachment["name"] . "\"\r\n";
                    $msg .= "Content-Transfer-Encoding: base64\r\n";
                    $msg .= "Content-Disposition: attachment; filename=\"" . $attachment["name"] . "\"\r\n\r\n";
                    $msg .= chunk_split($attachment["content"]) . "\r\n\r\n";
                }
            
                $msg .= "--" . $boundary . "--\r\n\r\n";
            }
            
            $r = @mail($this->to, $this->subject, $msg, $headers, "-f" . $this->from);
            if(!$r) {
                $headers = "To: " . $this->to . "\r\n" . $headers;
                $r = @mail($this->to, $this->subject, $msg, $headers);
            }
            return $r;
        }
    }
?>


A to jest plik index.php , w ktorym jest wstawiony formularz e-mail:
Kod
<div id="imPage">

<div id="imPage">

<div id="imCel8_00">
<div id="imCel8_00_Cont">
    <div id="imObj8_00">
<script type="text/javascript"><!--
function ChkFrm_8_00(oForm)
{
sAlert1 = "Brak wartości w polu ";
sAlert2 = "Niepoprawny adres e-mail ";
sAlert3 = "Nieprawidłowe pytanie kontrolne ";
if (!imCheckForm(1,"Itm_8_00_1",sAlert2 + "\'Podaj swój adres e-mail\'",0,"")) return false;
if (!imCheckForm(0,"Itm_8_00_2",sAlert1 + "\'Krótki opis\'",0,"")) return false;
if (!imCheckForm(0,"Itm_8_00_3",sAlert1 + "\'Załącznik\'",0,"")) return false;
return (true);
}
//--></script>
<form action="files/mail_home_8_00.php" method="post" onsubmit="return ChkFrm_8_00(this)" enctype="multipart/form-data">
<fieldset>
<div class="imLineProp">
<label for="Itm_8_00_1">
Podaj swój adres e-mail<span class="style1">*</span>:<br />
    <input class="imInput imInput_0" type="text" name="Itm_8_00_1" id="Itm_8_00_1" onfocus="imFocus(this,'#FFFFE1')" onblur="imFocus(this,'#FFFFFF')" />
</label>
</div>
<div class="imLineProp">
Krótki opis (branża, dochód itp)<span class="style1">* </span>:<label for="Itm_8_00_2"><br />
    <textarea class="imInput imInput_0" name="Itm_8_00_2" id="Itm_8_00_2" style="height: 240px; width: 616px;" onfocus="imFocus(this,'#FFFFE1')" onblur="imFocus(this,'#FFFFFF')"></textarea>
</label>
</div>
<div class="imLineProp">
<label for="Itm_8_00_3">
Załącznik<span class="style1">*</span>:<br />
    <input class="imInput imInput_0" type="file" name="Itm_8_00_3" id="Itm_8_00_3" onfocus="imFocus(this,'#FFFFE1')" onblur="imFocus(this,'#FFFFFF')" />
</label>
</div>
<div class="imAlign_center">
    <input class="imFormButton" type="submit" value=" Wyślij " />
    <input class="imFormButton" type="reset" value=" Wyczyść " />
</div>
</fieldset>
</form>




NA podstawie tego jestes w stanie mi powiedziec co mam wpisac zamiast klucz $_FILES?
nospor
@bubolski zacznik wkoncu używać właściwe bbcode. Do kodu php uzywa się BBCODE PHP a nie code.

Co zwraca ci:
print_r($_FILES);
?
bubolski
a gdzie masz taka linijke ? Lub jak sprawdzic co mi zwraca ? tongue.gif kurcze ciezko sie samemu uczyc ^^
PawelC
Masz wstawić w swój skrypt, ten kod który podał Ci nospor, i napisać co wyświetliło.
bubolski
ok zeby moc to sprawdzic musialem usunac ta linijke:

if ($_FILES["Itm_8_00_3"]["name"] != "") $oEmail->attachFile($_FILES["Itm_8_00_file_get_contents($_FILES["Itm_8_00_3"]["name"]),3"]["name"],$_FILES["Itm_8_00_3"]["type"]);
$oEmail->send();

bo caly czas przez nia wywalalo blad. Po wstawieniu zamiast niej print_r($_FILES); zwraca mi taka wartosc:


Array ( [Itm_8_00_3] => Array ( [name] => gov6.jpg [type] => [tmp_name] => [error] => 6 [size] => 0 ) )
nospor
No i masz blad:
[error] => 6
Teraz wejdź do manuala do dzialu upload i sobie zobacz co ten blad oznacza.
bubolski
znalazlem cos takiego ale nie specjalnie wiem jak to naprawic ;/

If you are having a UPLOAD_ERR_NO_TMP_DIR (#6) error then check if you're not using open_basedir. If so, make sure to add /tmp to open_basedir, like that (for apache2) :

php_admin_value open_basedir /home/bohwaz/:/tmp/

Don't forget the trailing slash.

ponawiam moja prosbe ;/ , bo jest potrzebne , a naprawde nie mam pojecia jak poprawic kod zeby nie bylo tego bledu i wysylalo normalnie zalacznik

odswiezam poniewaz nadal nie rozwiazalem problemu

questionmark.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.