Uploading an Image Help
Posted: Mon Apr 10, 2006 5:22 am
I'm trying to allow users to upload an image for use as there avatar.
At the moment I have this script, very basic and no limitations on file size or type at the moment!!!
I need to be able to rename the image so that it matches a users Primary Key before it is saved to the correct folder. I have there primary key in a variable: $user_number.
How do I go about doing this?
At the moment I have this script, very basic and no limitations on file size or type at the moment!!!
Code: Select all
<?php
if($submit)
{
$_FILES["file"]["name"]="FILEONE";
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
echo "Uploading " . $_FILES["file"]["name"];
echo " (" . $_FILES["file"]["type"] . ", ";
echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />";
echo "File is temporarily stored as ". $_FILES["file"]["tmp_name"];
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploads/" . $_FILES["file"]["name"]);
echo "File has been stored in your uploads directory.";
}
?>
<html>
<body>
<form action="<? echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<p>File Upload</p>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>How do I go about doing this?