PHP,Comment fonctionner include_once ?
                    
        
     
             
                    youssefyoussef
    
        
    
                    Messages postés
            
                
     
             
            6
        
            
                                    Statut
            Membre
                    
                -
                                     
le_joker_fou Messages postés 765 Date d'inscription Statut Membre Dernière intervention -
        le_joker_fou Messages postés 765 Date d'inscription Statut Membre Dernière intervention -
        Bonjour, 
SVP, comment fonctionner :include_once('Mail.php');
include_once('Mail_Mime/mime.php');
dans EasyPHP?
Le programme est pour but de télécharger un fichier et envoyez un mail.et c'est trouver en anglais.
Le programme est le suivant :
dans une page html :
<html>
<head>
<title></title>
</head>
<body>
<form method="POST" name="email_form_with_php"
action="php-form-action.php" enctype="multipart/form-data">
<label for='name'>Name: </label>
<input type="text" name="name" >
 
<label for='email'>Email: </label>
<input type="text" name="email" >
 
<label for='message'>Message:</label>
<textarea name="message"></textarea>
 
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="uploaded_file">
 
<input type="submit" value="Submit" name='submit'>
</form>
</body>
</html>
Dans une page PHP :
<?php
//Get the uploaded file information
$name_of_uploaded_file =
basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file =
substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file =
$_FILES["uploaded_file"]["size"]/1024;//size in KBs
//Settings
$max_allowed_file_size = 100; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
//Validations
if($size_of_uploaded_file > $max_allowed_file_size )
{
$errors .= "\n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
{
$allowed_ext = true;
}
}
if(!$allowed_ext)
{
$errors .= "\n The uploaded file is not supported file type. ".
" Only the following file types are supported: ".implode(',',$allowed_extensions);
}
//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= '\n error while copying the uploaded file';
}
}
include_once('Mail.php');
include_once('Mail_Mime/mime.php');
$message = new Mail_mime();
$message->setTXTBody($text);
$message->addAttachment($path_of_uploaded_file);
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
?>
                
            
                
    
    
    
        SVP, comment fonctionner :include_once('Mail.php');
include_once('Mail_Mime/mime.php');
dans EasyPHP?
Le programme est pour but de télécharger un fichier et envoyez un mail.et c'est trouver en anglais.
Le programme est le suivant :
dans une page html :
<html>
<head>
<title></title>
</head>
<body>
<form method="POST" name="email_form_with_php"
action="php-form-action.php" enctype="multipart/form-data">
<label for='name'>Name: </label>
<input type="text" name="name" >
<label for='email'>Email: </label>
<input type="text" name="email" >
<label for='message'>Message:</label>
<textarea name="message"></textarea>
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="uploaded_file">
<input type="submit" value="Submit" name='submit'>
</form>
</body>
</html>
Dans une page PHP :
<?php
//Get the uploaded file information
$name_of_uploaded_file =
basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file =
substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file =
$_FILES["uploaded_file"]["size"]/1024;//size in KBs
//Settings
$max_allowed_file_size = 100; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
//Validations
if($size_of_uploaded_file > $max_allowed_file_size )
{
$errors .= "\n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
{
$allowed_ext = true;
}
}
if(!$allowed_ext)
{
$errors .= "\n The uploaded file is not supported file type. ".
" Only the following file types are supported: ".implode(',',$allowed_extensions);
}
//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= '\n error while copying the uploaded file';
}
}
include_once('Mail.php');
include_once('Mail_Mime/mime.php');
$message = new Mail_mime();
$message->setTXTBody($text);
$message->addAttachment($path_of_uploaded_file);
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
?>
        A voir également:         
- PHP,Comment fonctionner include_once ?
- Easy php - Télécharger - Divers Web & Internet
- Comment faire fonctionner le chromecast - Guide
- Expert php pinterest - Télécharger - Langages
- Faire fonctionner un lecteur dvd sans télécommande - Forum Téléviseurs
- Retour a la ligne php ✓ - Forum PHP
5 réponses
                        
                    J'ai rien trouver sur ce que tu m'as donnée, ils m'ont informer d'installer un logiciel qui s'appelle PEAR pour faire fonctionner Mail et Mail_Mime dans la fonction include. Qui peut SVP, me guider à installer ce logiciel pour faire fonctionner cette fonction?
Aidez moi SVP?
    
                Aidez moi SVP?
                        
                    Le comportement est similaire à include(), mais la différence est que si le code a déjà été inclus, il ne le sera pas une seconde fois.
Tu demandes comment cela fonctionne dans EasyPHP ? Exactement de la même manière, PHP ne change pas. Tu souhaites utiliser la fonction mail() ? Essaie de reformuler ta question, on n'a pas très bien compris...
Mail() est normalement inclut par défaut dans EasyPHP, mais pour l'utiliser tu dois spécifier un serveur SMTP autre que localhost (sauf si ton PC est un serveur SMTP).
    
                Tu demandes comment cela fonctionne dans EasyPHP ? Exactement de la même manière, PHP ne change pas. Tu souhaites utiliser la fonction mail() ? Essaie de reformuler ta question, on n'a pas très bien compris...
Mail() est normalement inclut par défaut dans EasyPHP, mais pour l'utiliser tu dois spécifier un serveur SMTP autre que localhost (sauf si ton PC est un serveur SMTP).
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question