File Upload Using PHP and Get File Info

by Hiroshi on June 17, 2008

in File Upload

This script uploads the file in the same directory and give you some information about the file.

Functionality

– Uploads file in the same directory
– Gives information like file name, size in bytes and file type
– Determines Max File Size allowed

PHP Code

<?PHP
/**
  * Giombetti.com Snippets()
  *
  * @author Marc Giombetti
  * @description: This Snipplets shows how to upload a File to the Server! Please dont forget to CHMOD the directory to 777
  *
  */
 
if ($File&& $File != "none") {
echo "<b>Your File:</b>";
echo "File onto the server: $Fichier<br />";
echo "Sended File: $File_name<br />";
echo "Size : $File_size<br />";
echo "Tipe : $File_type<br />";
copy($File, $File_name);
}
 
echo"<form ENCTYPE=\"multipart/form-data\" ACTION=\"$HTTP_SERVER_VARS[PHPSELF]\" METHOD=\"POST\">";
echo"<input TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\">";
echo"Send this file: <input NAME=\"File\" TYPE=\"file\">";
echo"<input TYPE=\"submit\" VALUE=\"Send\">";
echo"</form>";
?>

Precautions

  • CHMOD ‘upload’ folder to 777 if it is at online server
  • Use enctype=”multipart/form-data” in form tag

Upload File and Get Info Script Download

Related Posts

Previous post:

Next post: