Displaying an uploaded file from $_FILES

I'm having some issues with uploading files from HTML to a PHP based web server. The following is my HTML code. No issues here I believe. \[code\]<html> <body> <form action="upload.php" method="post" enctype="multipart/form-data" action="2.2.2.cgi"> <input type="file" name="file" id="file" size="35"><br> <input type="submit" name="submit" id="submit" value="http://stackoverflow.com/questions/14469151/Submit"> </form> </body></html>\[/code\]PHP code: \[code\]<?phpdefine ('MAX_FILE_SIZE', 1000000);$permitted = array('image/gif', 'image/jpeg', 'image/png', 'image/pjpeg', 'text/plain');if ($_FILES['file']['type'] == $permitted && $_FILES['file']['size'] > 0 && $_FILES['file']['size'] <= MAX_FILE_SIZE) { move_uploaded_file($_FILES, $uploadedfile); echo ('<img src="'.$uploadedfile'" />');}?>\[/code\]I can't figure out how to make it work in PHP. I've been trying several different ways and the above code is just my latest desperate attempt at figuring it out by trying to store the value into a new variable. What I want to do is the following:
  • Restrict the type and size of files that can be uploaded.
  • Is the file a picture? Display the picture.
  • Is it a plaintext file? Display the contents of the file.
  • Is it an unpermitted file? Display the name, type and size of the file.
Any kind of hint or help in any way would be greatly appreciated. Thanks! PS. It's not going live, so any security issues are irrelevant at the moment.
 
Back
Top