Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-26-2011, 05:06 PM
djkfunk is offline djkfunk
Registered User

Join Date: Oct 2011
Posts: 7

HTML Email Notification

Hi, I just installed phUploader 1.3. Looks like a great product so far, and it looks like the support is equally great, so thanks for both.

I'm making some modifications. I need to receive an email when a file(s) are uploaded with a link to the file(s) as well as the name of the file(s) uploaded. I started by adding the code from this post: http://www.novahq.net/forum/showthread.php?t=44866. I then modified it so it's now HTML-based email.

This is what I have - inserted on line 266 right after:

$error.="<b>FAILED:</b> No files selected<br />";
}

(I changed my email for obvious reasons).

PHP Code:
If($success!="") {
$to "MyEmail@MyDomain.com";
$subject "New File Uploaded";

$message "
<html>
<head>
<title>New File Uploaded</title>
</head>
<body>
<p>A new file has been uploaded to the web server.</p>
<p><b>FILE NAME:</b> "
.$file_name[$i]."</p>
<p><b>URL:</b> <a href=\""
.$full_url.$file_name[$i].".".$file_ext[$i]."\" target=\"_blank\">".$full_url.$file_name[$i].".".$file_ext[$i]."</a></p>
</table>
</body>
</html>
"
;

// Always set content-type when sending HTML email
$headers "MIME-Version: 1.0" "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" "\r\n";

// More headers
$headers .= 'From: <noreply@MyDomain.com>' "\r\n";
// $headers .= 'Cc: MyBoss@MyDomain.com' . "\r\n";

mail($to,$subject,$message,$headers);
    } 
My files upload fine, and I receive an HTML email fine, but the file name does not show up (the words "file name" show but not the file name itself) - and the URL is incomplete - it shows the URL up to my Uploads folder and then stops. I'm sure I coded it incorrectly because the 2 parts not working were simply pasted from other areas (I'm a PHP noob). I also tried a PHP echo code for the file name <?php echo $file_name ?> but that didn't work either - I believe because the file name is not defined...(?)

Anyway, sorry if I said way more than I need to, just trying to be thorough...so the big question is, can anyone help? Again, I'd like the file names and URL's to show in the email, and the lines I'm looking for help with are:

HTML Code:
<p><b>FILE NAME:</b> ".$file_name[$i]."</p>
<p><b>URL:</b> <a href=\"".$full_url.$file_name[$i].".".$file_ext[$i]."\" target=\"_blank\">".$full_url.$file_name[$i].".".$file_ext[$i]."</a></p>
Thanks in advance!
Reply With Quote
  #2  
Old 10-26-2011, 06:23 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

You'll want to insert your code after line 246:
PHP Code:
If(move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i].".".$file_ext[$i])) { 
It should look like this:
PHP Code:
If(move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i].".".$file_ext[$i])) {
                        
    
$to "MyEmail@MyDomain.com"
    
$subject "New File Uploaded"
                        
    
$message 
    <html> 
    <head> 
    <title>New File Uploaded</title> 
    </head> 
    <body> 
    <p>A new file has been uploaded to the web server.</p> 
    <p><b>FILE NAME:</b> "
.$file_name[$i]."</p> 
    <p><b>URL:</b> <a href=\""
.$full_url.$file_name[$i].".".$file_ext[$i]."\" target=\"_blank\">".$full_url.$file_name[$i].".".$file_ext[$i]."</a></p> 
    </table> 
    </body> 
    </html> 
    "

                        
    
// Always set content-type when sending HTML email 
    
$headers "MIME-Version: 1.0" "\r\n"
    
$headers .= "Content-type:text/html;charset=iso-8859-1" "\r\n"
                        
    
// More headers 
    
$headers .= 'From: <noreply@MyDomain.com>' "\r\n"
    
// $headers .= 'Cc: MyBoss@MyDomain.com' . "\r\n"; 
                        
    
mail($to,$subject,$message,$headers); 

    
$success.="<b>SUCCESS:</b> ".$_FILES['file']['name'][$i]."<br />";
    
$success.="<b>URL:</b> <a href=\"".$full_url.$file_name[$i].".".$file_ext[$i]."\" target=\"_blank\">".$full_url.$file_name[$i].".".$file_ext[$i]."</a><br /><br />";
                        
} Else {
    
$error.="<b>FAILED:</b> ".$_FILES['file']['name'][$i]." <b>REASON:</b> General upload failure.<br />";

__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 10-26-2011, 06:39 PM
djkfunk is offline djkfunk
Registered User

Join Date: Oct 2011
Posts: 7

works great, thank you!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:27 AM.




Powered by vBulletin®