Http Header question

William Prothero prothero at earthednet.org
Tue Jan 19 20:38:39 EST 2016


Folks:
Dave got me started, but I’m still confused, unfortunately. I am having trouble seeing how the variables and data are passed from the POST command to the php script. What I’m trying to reproduce is:

<?php
   if(isset($_FILES['image'])){
      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size =$_FILES['image']['size'];
      $file_tmp =$_FILES['image']['tmp_name'];
      $file_type=$_FILES['image']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
      
      $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){
         move_uploaded_file($file_tmp,"images/".$file_name);
         echo "Success";
      }else{
         print_r($errors);
      }
   }
?>
<html>
   <body>
      
      <form action="" method="POST" enctype="multipart/form-data">
         <input type="file" name="image" />
         <input type="submit"/>
      </form>
      
   </body>
</html>

I’m familiar with a php script getting variables from lines like:
$tName =  $_POST["name"];

But, in the above example, how do the file variables get sent? I suppose, in the headers? But, I don’t seem to be successful. The file doesn’t seem to be passing to the php. I’m thinking that the image data gets embedded in the header, but I don’t see the file on my server and nothing seems to be getting into the $_FILES variable.

Help?? thanks. 
Bill


> On Jan 19, 2016, at 3:55 PM, William Prothero <prothero at earthednet.org> wrote:
> 
> Dave:
> That’s it! I knew there was something like that, but couldn’t remember it. 
> Thanks!
> Bill
> 
>> On Jan 19, 2016, at 3:51 PM, Dave Cragg <dcragg at lacscentre.co.uk> wrote:
>> 
>> Bill,
>> 
>> Take a look at libUrlMultipartForm and libUrlMultipartFormAddPart in the dictionary. There are examples there that might help you.
>> 
>> Cheers
>> Dave Cragg
>> 
>> 




More information about the Use-livecode mailing list