> From: Mark Colvin [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 18, 2002 10:09 AM
>
>                               -- upload.php --
> <?php
> 
> if ('img1' != "") {
This will allways be true! 'img1' is a string and will never be empty.
You probably mean if($img1 != "")
However, I'm not sure this will work in this case.

Try this instead. (Taken straight from the PHP-manual. A real good
resource!)

<?php
if (is_uploaded_file($_FILES['img1']['tmp_name']))
{
        $filename = $_FILES['img1']['tmp_name'];
        print "$filename was uploaded successfuly";
        $realname = $_FILES['img1']['name'];
        print "realname is $realname";
        print "copying file to uploads dir";
        copy($_FILES['img1']['tmp_name'], "/place/to/put/" . $realname);
}
else
{
        echo "Possible file upload attack: filename" .
$_FILES['img1']['name'] . ".";
}
?>

If you use PHP < 4.1.0 you must exchange $_FILES to $HTTP_POST_FILES

Regards
Joakim Andersson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to