Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.