Sending automatic email after an upload
Hi there; I was struggling to make jquery file upload send me an email after someone upload a file. Guess you can help me in figure it out. I've setted up a php file that, if invoked, send me the mail I want but I don't know how to get it from the jquery file upload script. Hope you can help me. Ask me if you need further information. Please!
Put the code to send the email in server/php/upload.class.php
Great, it works! But now I have an additional problem: when I upload a file the system returns me this error: "SyntaxError: JSON.parse: unexpected character". I know it depends on the PHP code I've inserted, but I don't know why and how to solve it. Can you help me again? Here's the code I've inserted: $mail = new PHPMailer();
$mail->From = "upload@email"; $mail->FromName = "name"; $mail->AddAddress("myemail@email"); $mail->IsHTML(true);
$mail->Subject = "{$context[user][name]} ,..";
$mail->Body = "Part of the message
{$context[user][name]}Another part of the message
another part between brtag
";
$mail->WordWrap = 50;
if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; }
The code looks fine it must be where you inserted it that is causing the problem. Paste the entire file after you've inserted the code https://gist.github.com/
Firstly, let me thank you for your patient help. Here's the whole code: https://gist.github.com/7b04be7898e098c1c9db . Actually I didn't know where to insert the code...
Try something like https://gist.github.com/2cbf8d2c668e6f0441f1
Nope, this way I don't even receive the mail. Guess the function sendmail() doesn't work properly. I have also tried with the strict syntax of that function ( function sendmail($to... etc.) ) but still didn't work. Is there a way to make only run the code I posted above within a function? E.g. a "function run()"...?
Ok, I reach my goal. I put the code in the index.php file which is in the same folder of upload.class.php and it works. Then I have my last question. How do I retrieve the filename of the uploaded file? I tried with $file_name but it didn't work. Meanwhile thank you for everything in advance and for what you'll eventually do in advance.
add print_r($_FILES, true) to the email body to get a output of file info
It works, but returns me a list of arrays. Not very intelligible. Is there a way to display only the filename? :)
foreach ($_FILES as $f)
$body .= $f['name'] . "<br>";
You're great. This
foreach ($_FILES as $f)
$body .= $f['name']['0'] . "
";
works.
Fantastic. Let me thank you another time :)
Dear All,
I have the same problem.but it very complex for me to understand this because there is modified file but after that there is several posts.so plase can you explain it bit more.this is really urgent.
Thanks