嗨,我刚刚启动并运行了这个视频上传器,它工作得很好。但是,我想要通知我的电子邮件,让我知道有人刚刚将视频上传到我的服务器。但它没有通知我,我已经完全简化了它只是为了得到某种信息给我,但它只是没有运作我错过了什么?
if(isset($_FILES["FileInput"]) && $_FILES["FileInput"]["error"]== UPLOAD_ERR_OK)
{
$UploadDirectory = '../video_uploader/uploads/';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
die();
}
//Is file size is less than allowed size.
if ($_FILES["FileInput"]["size"] > 500242880) {
die("File size is too big!");
}
//allowed file type Server side check
switch(strtolower($_FILES['FileInput']['type']))
{
//allowed file types
case 'image/png':
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
case 'text/plain':
case 'text/html': //html file
case 'application/x-zip-compressed':
case 'application/pdf':
case 'application/msword':
case 'application/vnd.ms-excel':
case 'video/mp4':
break;
default:
die('Unsupported File!'); //output error
}
$File_Name = strtolower($_FILES['FileInput']['name']);
$File_Ext = substr($File_Name, strrpos($File_Name, '.'));
$Random_Number = rand(0, 9999999999); //Random number to be added to name.
$NewFileName = $Random_Number.$File_Ext; //new file name
if(move_uploaded_file($_FILES['FileInput']['tmp_name'], $UploadDirectory.$NewFileName ))
{
die('Success! File Uploaded.');
}else{
die('error uploading File!');
}
}
else
{
die('Something wrong with upload! Is "upload_max_filesize" set correctly?');
}
mail("me@myemail.com.", $NewFileName);
?>`
答案 0 :(得分:2)
试试这个。根据你的需要改变字段。
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: me@myemail.com" . "\r\n";
$headers .= "From: demo.com <contact@demo.com>" . "\r\n";
mail('me@myemail.com', $subject, $message, $headers);
// subject and message just choose according to your needs and it should be in html format.
进一步参考请点击这些链接
http://www.w3schools.com/php/php_ref_mail.asp
http://php.net/manual/en/function.mail.php
答案 1 :(得分:1)
这不是php邮件的工作原理。它需要标题,主题和消息。如果没有合适的标题,电子邮件就不会发送,因为它不知道该怎么回事。此外,当您完成所有设置时:&#34;检查您的spambox&#34;
答案 2 :(得分:0)
在本节中再次检查您的代码:
if(move_uploaded_file($_FILES['FileInput']['tmp_name'], $UploadDirectory.$NewFileName ))
{
die('Success! File Uploaded.');
}
else
{
die('error uploading File!');
}
因此,如果您的文件上传失败,您的脚本会因为错误消息而死亡()
另一方面,如果您的上传成功,则您的脚本会再次死亡()
这听起来合乎逻辑吗?您的脚本永远不会到达发送电子邮件的位置
此外,mail()函数需要3个参数,正如其他人所建议的那样。