File Uploading System

Written by @m_k_amin 20 November 2012

This is a self file upload script. No need to html file for for uploading. Enjoy!

Code Snippet:

                                                
                                                <!-- this script is provided by https://www.phpfreecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.phpfreecpde.com, Coded by: Kerixa Inc-->

<?php
if (isset ($_GET['type'])&& $_GET['type']=="send"){
	if ($_FILES['userfile']['error']==0) {
          /*echo 'File Name: '.$_FILES['userfile']['name'].'<br>';
          echo 'File Type: '.$_FILES['userfile']['type'].'<br>';
          echo 'File Size: '.$_FILES['userfile']['size'].'<br>';
          echo 'Temporary Name: '.$_FILES['userfile']['tmp_name'].'<br>';*/
          $tmpFile= $_FILES['userfile']['tmp_name'];
          $newFile=getcwd().'/'.$_FILES['userfile']['name'];
          if (move_uploaded_file($tmpFile, $newFile))
                   echo '
                   <p style="text-align: center;font-size: 17pt;color: #008000;"><strong>Your file is uploaded successfully.</strong></p>
					';
          else
                   echo '
                   <p style="text-align: center;font-size: 17pt;color: #FF0000;"><strong>An error occurred while uploading.</strong></p>
					';
	}else
          echo 'An Error occuerd NO.: '.$_FILES['userfile']['error'].'<br>';
}
?>
<html><body>
    <div style="text-align: center; height: 58px;background-color: #DFDFFF;" >
<form enctype= "multipart/form-data" action= "<?php echo $_SERVER['PHP_SELF'].'?type=send' ?>" method= "POST" style="background-color: #DFDFFF;">
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    	<span style="color: #008000;">
	<strong><span style="font-size: 20pt;">Upload Your File:
</span><br>
</strong></span><br style="font-size: 20pt;"><span style="font-size: 15pt;"><strong>File: </strong>
		</span> <input name="userfile" type="file" style="width: 253px" /> <br>
		<br style="font-size: 10pt;">
    <input type="submit" value="Send" style="width: 86px; height: 43px" />
    <br><font face="Tahoma"><a target="_blank" href="http://www.phpfreecode.com/"><span style="font-size: 8pt; text-decoration: none">PHP Free Code</span></a></font>

</form></div>
</body></html><a target='_blank' href='https://www.phpfreecode.com' style='font-size: 8pt; text-decoration: none'>Php Best Codes</a>                                                
                                            

Example:


About @m_k_amin

This user is pending a biography.

M

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: grkkid, Manaakividuinfo.com, karticksv, sava, tinatina
advertisement 2