|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Help needed for debugging a mailing with attachmeny in PHP
I have use a very close version of this script in many web site but this one doesn't work. It's a mailing list with file attached.
Code:
// I drop the file on the server
if(!empty($_FILES['fichier'])){
$nom = substr($_FILES['fichier']['name'], strripos($_FILES['fichier']['name'], '.'));
$extension= substr($nom, 1, 3);
$connection = ftp_connect('cld-charlevoix.org') or die("connection impossible");
ftp_login($connection, $user, $password) or die("user erreur ou mot de passe");
ftp_put($connection,("/public_html/admin/attachement/".$_FILES['fichier']['name']),$fichier,FTP_BINARY) or die("le transfert marche pas");
ftp_close($connection);
echo "go";
}
// then i create the script for the mailing
if(isset($_POST['groupe'])){
//---------------------------------------------------------- ramasse le texte et le titre
$sql_texte2=mysql_query("SELECT * FROM texte WHERE id_texte='18'");
$ligne_texte2=mysql_fetch_array($sql_texte2);
$titre_texte2=$ligne_texte2['titre']; // le titre du message
//------------------------------------------
foreach($_POST['groupe'] as $lesgroupes) {
if($_POST['groupe'][0] !='tous'){
$sql_listeenvoi=mysql_query("SELECT * FROM listeenvoi where groupe='".$lesgroupes."' and actif='oui' ORDER BY courriel ASC");
}
else{
$sql_listeenvoi=mysql_query("SELECT * FROM listeenvoi where actif='oui' ORDER BY courriel ASC");
}
$i=1;
while($ligne_listeenvoi=mysql_fetch_array($sql_listeenvoi)){
$to = "".$ligne_listeenvoi['courriel']."";
//------------------------------------------
$sujet = $titre_texte2;
$delimiteur=md5(uniqid(rand()));
$entete = "MIME-version: 1.0\n";
$entete .= "From:info@cld-charlevoix.org\n";
$entete .= "Content-type: multipart/mixed; boundary=".$delimiteur." \n ";
$entete .= " \n";
$sujet = $titre_texte;
$message ="--".$delimiteur."\n";
$message .= "Content-type: text/html; charset= \"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding:8bit\n";
$message .= "\n";
$message .="Hello";
$message .= "\n";
$message .="--".$delimiteur." \n";
if(!empty($_FILES['fichier']['name'])){
$fichier ="attachement/".$_FILES['fichier']['name']."";
$attache = file_get_contents($fichier);
$attache = chunk_split(base64_encode($attache));
$message .="--".$delimiteur." \n";
$message .="Content-Type: application/".$extension."; name=".$fichier." \n";
$message .="Content-Transfer-Encoding: Base64\n";
$message .="Content-Disposition: inline; filename=".$fichier." \n";
$message .= "\n";
$message .= $attache." \n";
$message .= "\n";
$message .="--".$delimiteur." \n";
}
mail($to,$sujet,$message,$entete, "-flamuse@lamuse.com");
}}}
echo "$to<br>";
?>
Any suggestion will be welcomed |
|
|
|
0
|
|
|
#2 |
|
Not a clue what you mean by "not interpreted" so if this advice does not help you need to explain exactly what you mean and what happened when you run the script.
In PHP uploaded files are stored in a temporary location and must be copied to a real folder to attach or FTP, whatever. I don't see something similar in concept to this, which moves the uploaded temp file to a REAL folder with the proper name in this example called upload. Edit to suit your own needs: PHP Code:
__________________
Jim Goldbloom Sr. Web Developer, owner GoldTechPro, LLC http://www.GoldTechPro.com
|
|
|
|
0
|
|
|
#3 | |
|
Quote:
The file is already upload to the server : Code:
if(!empty($_FILES['fichier'])){
$nom = substr($_FILES['fichier']['name'], strripos($_FILES['fichier']['name'], '.'));
$extension= substr($nom, 1, 3);
$connection = ftp_connect('cld-charlevoix.org') or die("connection impossible");
ftp_login($connection, $user, $password) or die("user erreur ou mot de passe");
ftp_put($connection,("/public_html/admin/attachement/".$_FILES['fichier']['name']),$fichier,FTP_BINARY) or die("le transfert marche pas");
ftp_close($connection);
echo "go";
}
|
||
|
|
0
|
|
|
#4 |
|
The actual file is stored in $_FILES["file"]["tmp_name"] and you must move it as in my example code. Then you can FTP or attach via email, etc. I already told you I don't see the move command anywhere in your code.
Did you login to the FTP server and not only confirm the file name is there but that it's the actual image? Download it manually to be sure. To me looks like you're uploading a file name, not a binary. And in your email code, no move command so binary and it would end up the way you see it now. Anyone else following this please correct me if I'm wrong on this or missing something obvious!
__________________
Jim Goldbloom Sr. Web Developer, owner GoldTechPro, LLC http://www.GoldTechPro.com
|
|
|
|
0
|
|
|
#5 | |
|
Quote:
Code:
ftp_put($connection,("/public_html/admin/attachement/".$_FILES['fichier']['name']
Code:
$connection = ftp_connect('cld-charlevoix.org') or die("connection impossible");
ftp_login($connection, $user, $password) or die("user erreur ou mot de passe");
Nomade |
||
|
|
0
|
|
|
#6 |
|
I mean this respectfully, but the code you posted is how to ftp a file in PHP but you must have some other code you'r not telling us about that places the file in the source server path specified PRIOR to FTP based on your code as posted here.
Look at this example written by someone else on php.net which I am copying to show you they're using the 'tmp_name' key of the $_FILES array to create the variable that stores the actual file: PHP Code:
I want to be clear on this -- $_FILES['file_name'] does not store the actual file when processing server side immediately after an upload. $_FILES['tmp_name'] does and is physically stored in the temp path on your server unless you move it, otherwise when the PHP script ends it is removed from the server. I'll leave it to others to jump in, I've done all I can do on this one.
__________________
Jim Goldbloom Sr. Web Developer, owner GoldTechPro, LLC http://www.GoldTechPro.com
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:48 PM.







Jim Goldbloom
Linear Mode
