# Upload

**URL:** <https://forum.kirupa.com/t/upload/171769>\
**Category:** Uncategorized\
**Created:** [December 8, 2005, 1:30am UTC](https://forum.kirupa.com/t/upload/171769 "2005-12-08T01:30:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cxn926](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@cxn926](https://forum.kirupa.com/u/cxn926)\
**Post date:** [December 8, 2005, 1:30am UTC](https://forum.kirupa.com/t/upload/171769/1 "2005-12-08T01:30:50Z")

</div>

I have this code in the php file

```php
 <?php
$file_size = $_FILES['file']['size'];
if($file_size > 1048576){
print"Your File Size Exceeded the Limit of 1 Megabyte.";
}else{
 
$oldfile = basename($_FILES['file']['name']);
// getting the extention
$pos = strpos($oldfile,".",0);
$ext = trim(substr($oldfile,$pos+1,strlen($oldfile))," ");
 
if($ext == swf || jpeg || jpg || gif || png || tiff || rif || bmp){
 
 
$target_path = "/";
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['file']['name']);
$_FILES['uploadedfile']['tmp_name']; 
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
	 echo "The file ". basename( $_FILES['file']['name']). " has been uploaded<br \>";
} else{
	 echo "There was an error uploading the file, please try again!"; 
} 
}else{
print'Not a current file type that can be uploaded';
}
}
 
?> 

```

That works perfectly fine and just to say this is my html code.

```auto
<html>
<head>
<title>Upload Your File</title>
</head>
<body>
<form action="manage.php" method="post" enctype="multipart/form-data">
<input type=file name=file> <BR>
<input type="submit" value="Upload">
</form>
</body>
</html>

```

I want it so when it uploads, on the same page as the upload page(html page) there is a box that says where the file is. Also i want it so when it uploads the file it changes the name to random letters so people don’t upload the same file twice and it overwrites each other. I hope this isn’t too much to ask.
