Php form upload and email

前端 未结 1 1392
一向
一向 2021-01-28 20:23

I have the following code, ideally, it is expected that the user shall upload a file(image/video) when submitting the form, but it is not compulsory though.

<         


        
相关标签:
1条回答
  • 2021-01-28 21:11

    it runs on page load

    enclose mail send feature in

    if(isset($_POST['Submit']) && ($_POST['Submit']) == 'Send' )
    {
      /* process only when submit button whose name='Submit' 
         and value= 'Send' is pressed
         entire PHP code */
    }
    

    if file has not been uploaded, it throws a warning.

    check before attaching it in PHP

    if((empty($_POST['attachment'])) || (empty($_FILES['attachment']))){
        //file is not attached, show error
    }else{
     //file is attached, process it and send via mail
    }
    
    0 讨论(0)
提交回复
热议问题