Http Header question

William Prothero prothero at
Tue Jan 19 17:44:41 EST 2016

I’m setting up a php sendmail script using phpSendmail and I’m trying to get the file upload for attachments part working. The examples I find are in html and the “type" is listed as “file”.

Basically, I’m trying to reproduce this, in a “post” command:

      <form action = "" method = "POST" enctype = "multipart/form-data">
         <input type = "file" name = "image" />
         <input type = "submit"/>
            <li>Sent file: <?php echo $_FILES['image']['name'];  ?>
            <li>File size: <?php echo $_FILES['image']['size'];  ?>
            <li>File type: <?php echo $_FILES['image']['type'] ?>
I figure it is probably a change in the http header, to get php to recognize the file as an upload, but I don’t know how to do this. Somehow, the php needs to get the filepath that I provide it, but ….. 

Any help would be very appreciated.

PS: The php in the example I’m trying to duplicate is:

      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size = $_FILES['image']['size'];
      $file_tmp = $_FILES['image']['tmp_name'];
      $file_type = $_FILES['image']['type'];
      $expensions= array("jpeg","jpg","png");
      if(in_array($file_ext,$expensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
      if($file_size > 2097152) {
         $errors[]='File size must be excately 2 MB';
      if(empty($errors)==true) {
         echo "Success";

William Prothero, Ph.D.
University of California, Santa Barbara, Emeritus
prothero at

More information about the Use-livecode mailing list