Jump to content

IF variable question


kyleldi

Recommended Posts

I've got a form online now that generates its data and emails me with the results.  On that form is a attachment section where a URL to the file is sent in the email to be downloaded.  Sometimes I don't receive an attachment in the file, which makes the url come back dead.  I'm unsure how to do this, but how can I create an IF statement that if a file is not uploaded, it simply puts "Customer Did Not Attach A File" where it would usually post a URL.  It would also record this information in the database instead of the URL.  Is this possible?  Here's my code...

 

if($HTTP_POST_FILES['AttachPrint']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['AttachPrint']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['AttachPrint']['name'].", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['AttachPrint']['name'];
$image_list[13] = $image_part;
copy($HTTP_POST_FILES['AttachPrint']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

Link to comment
https://forums.phpfreaks.com/topic/65989-if-variable-question/
Share on other sites

EDIT: oops

updated

 

add 1 lines

if($HTTP_POST_FILES['AttachPrint']['tmp_name']==""){ 
echo "No file attached"; //add (between the {}
}else if(!is_uploaded_file($HTTP_POST_FILES['AttachPrint']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['AttachPrint']['name'].", was not uploaded!";
$errors=1;
}

Link to comment
https://forums.phpfreaks.com/topic/65989-if-variable-question/#findComment-329963
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.