Uploading image and renaming it

They have: 7 posts

Joined: Jun 2004

I've been studying file uploading from PHP.net and I got files uploaded. The only problem I have now is that I can't define what I want image name to be when it's in server. For example I upload image.png and I want that it's name in server is 1.png.

I have now this script:
I've tried changing $uploadfile = $uploaddir . $_FILES['image']['name']; to
$uploadfile = $uploaddir . "1.png"; but it doesnt work after i do that.

<?php
                $uploaddir
= '/home/mikko/www/images/upload/';
       
$uploadfile = $uploaddir . $_FILES['image']['name'];
        print \
"<pre>\";
        if (move_uploaded_file(
$_FILES['image']['tmp_name'], $uploadfile ))
            {
                print \"File is valid, and was successfully uploaded. \";
                print \"Here's some more debugging info:\n\";
                print_r(
$_FILES);
            }
        else
            {
                print \"Possible file upload attack!  Here's some debugging info:\n\";
                print_r(
$_FILES);
            }
        print \"</pre>\";
?>

What should I change in this script so that image name would always be 1.png? I really have been thinking this but I haven't got it work. Usually when I change something it just goes to that else

- Keripukki