kyleldi Posted August 21, 2007 Share Posted August 21, 2007 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 More sharing options...
nathanmaxsonadil Posted August 21, 2007 Share Posted August 21, 2007 what does your html look like? you could use a thing like this if(empty($_POST['upload'])) //do whatever you want here } Link to comment https://forums.phpfreaks.com/topic/65989-if-variable-question/#findComment-329960 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 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 More sharing options...
kyleldi Posted August 21, 2007 Author Share Posted August 21, 2007 sweet, thanks Link to comment https://forums.phpfreaks.com/topic/65989-if-variable-question/#findComment-329966 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 can you please click solved (bottom left) Link to comment https://forums.phpfreaks.com/topic/65989-if-variable-question/#findComment-329971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.