Okay I\'m totally new in this field and going through some tutorials and I found that while uploading files in PHP it stores them in a temporary location.
$file
Two additional reasons:
If you decide not to accept the file for some reason, it's stored in a temporary location and presumably will be automatically deleted at some point.
Security. Let's say PHP was set to upload to a web-accessible directory like /images. Someone could upload some sort of hacking file and then execute it. By putting files in a temporary directory first (which will usually not be web-accessible), PHP lets you examine the file first. For instance, by processing images to remove any comments that could contain PHP code.