Click here to Skip to main content
12,623,903 members (29,434 online)
Click here to Skip to main content
Articles » Web Development » PHP » General » Downloads

Stats

10.6K views
456 downloads
8 bookmarked
Posted

PHP SimpleSix Uploader

, 9 Apr 2012 CPOL
A simple file uploader written in PHP.
<?

	$file = $_FILES['file'];
	$name = $_POST['name'];
	$path = $_POST['path'];
	$upload = $_POST['upload'];
	
	if(isset($upload)){
		
		if($file['name']){
			
			if($name){
				
				if(strlen($path) > 5){
					
					move_uploaded_file($file['tmp_name'], $path.$name);
					
					echo "<font color=green>File successfully uploaded!</font>";
				
				} else 
					echo "<li> Please enter the path!";
			
			} else 
				echo "<li> Please put the file name!"; 
		
		} else 
			echo "<li> No file to upload";
			
		echo "<br /><hr />";
	}

?><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <form method="post" enctype="multipart/form-data">
    <tr>
    <td height="40" colspan="2"><h2><strong>Uploader</strong></h2></td>
  </tr>
  <tr>
    <td height="25">File:</td>
    <td><label>
      <input name="file" type="file" id="file" size="35">
    </label></td>
  </tr>
  <tr>
    <td width="1%" height="25" nowrap>Re-name file:&nbsp;</td>
    <td><label>
      <input type="text" name="name" id="name">
      <em>(ex.filename.txt)</em></label></td>
  </tr>
  <tr>
    <td height="25" bgcolor="#FAFAFA">Path to:</td>
    <td bgcolor="#FAFAFA"><label>
      <input name="path" type="text" id="path" size="30">
      <em>(ex. folder/dir/.../)</em></label></td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
    <td><label>
      <input type="submit" name="upload" id="upload" value="Up..">
    </label></td>
  </tr>
  <tr>
    <td height="10" colspan="2">&nbsp;</td>
    </tr>
  <tr>
    <td height="10" colspan="2"><em>Uploader path: <?= getcwd(); ?></em></td>
  </tr>
  </form>
</table>
<p>Author: <strong>Agon Avdimetaj</strong></p>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Agon Avdimetaj
CEO Graphsix Studio
Albania Albania
CEO / Web & App Developer @ Graphsix Studio.
Studying Computer Engineering @ Faculty of Electrical and Computer Engineering, UP.

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161128.1 | Last Updated 9 Apr 2012
Article Copyright 2012 by Agon Avdimetaj
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid