Предупреждение: fopen (): Имя файла не может быть пустым [dублировать]

Отправить письмо с кодом вложения отлично работает, недавно мы передали файл на другой сервер хостинга idk, из-за чего он отображает следующую ошибку,

Warning: fopen (): имя файла не может быть пустым в / home /hugerecruitmetnt/public_html/validatecva.php в строке 106 Предупреждение: fread () ожидает, что параметр 1 будет ресурсом, boolean указан в /home/hugerecruitmetnt/public_html/validatecva.php в строке 107 Предупреждение: fclose () ожидает, что параметр 1 будет ресурсом , boolean задано в /home/hugerecruitmetnt/public_html/validatecva.php в строке 148 Предупреждение: невозможно изменить информацию заголовка - заголовки, уже отправленные (вывод запущен в /home/hugerecruitmetnt/public_html/validatecva.php:106) в / home / hugerecruitmetnt /public_html/validatecva.php в строке 150
   <?php 
$name = $_POST['fname']; 
$initial = $_POST['mname']; 
$surname = $_POST['lname']; 
$gender = $_POST['gender']; 
$dob = $_POST['dob'];
$nationality = $_POST['nationality'];
$address = $_POST['fulladdress'];
$passport = $_POST['passportno'];
$passexpiry = $_POST['passexpiry'];
$mobile = $_POST['mobile'];
$email_address = $_POST['email'];
$filename=$_FILES["newfile"]["name"]; 
$filetype=$_FILES["newfile"]["type"]; 
$filesize=$_FILES["newfile"]["size"]; 
$filetemp=$_FILES["newfile"]["tmp_name"]; 

if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword" or $filetype=="application/zip" or $filetype=="application/pdf" or $filetype=="application/vnd.openxmlformats-officedocument.wordprocessingml.document") 
{ 

$message= '<table cellspacing="0" cellpadding="8" border="0" width="400"> 
<tr> 
<td colspan="2"></td> 
</tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$fname.'  '.$initial.'  '.$surname.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Gender</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$gender.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Date Of Birth</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$dob.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>nationality</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$nationality.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$fulladdress.'</td> 
</tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Passport No</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$passportno.'</td> 
</tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Passport Expiry</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$passexpiry.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Email</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$email.'</td> 
</tr> 
<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 

<tr bgcolor="#eeeeee"> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Mobile</strong></td> 
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$mobile.'</td> 
</tr>               

<tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 
</table> 
'; 

// MAIL SUBJECT 
$subject = "Posted CV From "; 

// TO MAIL ADDRESS 
$to = 'email@email.com';



/* 
// MAIL HEADERS 

$headers  = "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; 
$headers .= "From: Name <name@name.com>\n"; 

*/ 
// MAIL HEADERS with attachment 
$fp = fopen( $newfile, "rb"); 
$file = fread($fp, $newfile_size); 
$file = chunk_split(base64_encode($file)); 
$num = md5(time()); 

//Normal headers 

$headers  = "From: $name<$email>\r\n"; 
$headers  .= "MIME-Version: 1.0\r\n"; 
$headers  .= "Content-Type: multipart/mixed; "; 
$headers  .= "boundary=".$num."\r\n"; 
$headers  .= "--$num\r\n"; 

// This two steps to help avoid spam    

$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; 
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";          

// With message 

$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "Content-Transfer-Encoding: 8bit\r\n"; 
$headers .= "".$message."\n"; 
$headers .= "--".$num."\n";  

// Attachment headers 

$headers  .= "Content-Type:".$newfile_type." "; 
$headers  .= "name=\"".$newfile_name."\"r\n"; 
$headers  .= "Content-Transfer-Encoding: base64\r\n"; 
$headers  .= "Content-Disposition: attachment; "; 
$headers  .= "filename=\"".$newfile_name."\"\r\n\n"; 
$headers  .= "".$file."\r\n"; 
$headers  .= "--".$num."--"; 



// SEND MAIL 

@mail($to, $subject, $message, $headers); 


fclose($fp); 

header('Location: thankscv.php');
} 
else 
{ 
echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Wrong file format. Mail was not sent.</font>'; 
//echo "<script>window.location.href='careers.html';</script>"; 
} 
-3
задан 29 June 2015 в 15:11

1 ответ

Размер загружаемого файла temp по умолчанию равен 2mb. Увеличить размер.

upload_max_filesize=2M

TO

upload_max_filesize=100M

в php.ini xampp и после этого перезапустить xampp. Я надеюсь, что вы не получите никаких ошибок и что файл будет также прочитан.

0
ответ дан 15 August 2018 в 15:40

Другие вопросы по тегам:

Похожие вопросы: