Http Header question

Peter Haworth pete at lcsql.com
Wed Jan 20 18:50:48 CET 2016


If you were doing this from an html form, the file in question would be
uploaded to the server's temp directory and the php script can access it
from there using the "tmp_name" key.  I think the $_FILES array is created
as a result of the  enctype setting.  Not sure how you would replace all
that via LC though.

On Tue, Jan 19, 2016 at 5:38 PM William Prothero <prothero at earthednet.org>
wrote:

> 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
> >>
> >>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


More information about the use-livecode mailing list