Hey guys! Recently (today as it happens) I have made an upload script, for where my users can upload a picture, this picture will then be used as there display picture in the profile... Like on forums! A few things that are wrong with this are:
The file keeps original name, maybe need to change incase someone else uploads same file name but different file.
The file type; uses only pictures
Anyone know how I can resolve this?
PHP Code:
<html><head><title>XinGs Upload script</title></head></html>
<?
if(isset($submit)) {
$target_path = "uploads/";
$filesize = 100000;
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<br>";
echo "You can see your file at: <a href=\"./$target_path\">HERE</a>";
} else{
echo "There was an error uploading the file, the file is possibly too large!!";
echo "<br>";
echo "The max file size is: $filesize kb";
}
} else {
?>
<form enctype="multipart/form-data" action="<? $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="<? echo "$filesize"; ?>" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" name="submit" value="Upload File" />
</form>
<br>
View other peoples uploaded files <a href="./uploads/">here!</a>
<?
}
?>
Last edited by feraira; 06-16-2005 at 08:33 PM..
|