Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Good games for the PSP?
05-27-2008 02:50 PM
Last post by PureDeceit
Today 01:28 AM
67 Replies, 369 Views
Go to first new post Everyone with Kyo in...
Yesterday 04:18 PM
by Kyo
Last post by Kyo
Today 01:24 AM
292 Replies, 293 Views
Go to first new post Warhammer Online Beta
Today 01:13 AM
Last post by alvinthecat
Today 01:13 AM
0 Replies, 1 Views
Go to first new post God that must've SUCKED
Yesterday 09:31 PM
Last post by alvinthecat
Today 01:02 AM
2 Replies, 3 Views
Go to first new post Inuyasha or Naruto?
04-13-2008 12:58 PM
Last post by Pandox
Today 12:57 AM
84 Replies, 445 Views
Reply
 
LinkBack Thread Tools Display Modes

 PHP file uploader
Old 10-18-2006, 03:39 PM   #1 (permalink)
Oosband
Guest
 
Posts: n/a
iTrader: / %
PHP file uploader

Want to make a simple PHP file uploader for your site?
Here it is!

Code:
<?php

$action = $_POST["action"];
$max_size = "10485760"; // Max size in BYTES (Currently 10MB)

echo "
<html>
<center>
<form action='upload.php' method=post  enctype='multipart/form-data'>
Select A File To Upload:


<input type='file' name='filename'>


<input type='reset' value='Reset'>
<input type='hidden' name='action' value='upload'>
<input type='submit' value='Upload File'>
</form>";


if ($action == 'upload')
{
	
	
	if ($_FILES["filename"]["size"] > $max_size) die ("File too big!  Try again...");
	
	
	copy($_FILES["filename"]["tmp_name"],"./".$_FILES["filename"]["name"]) or die("<font color='red'>Unknown error! Please e-mail me if the problem persists.</font>");
	echo "<font color='green'>File Uploaded. Click here to see your file(s).</font>"; // for debug -->  $filename --> ".$destination."/".$filename_name."</h2>";
	
	
}
	
?>
The variables at the beginning set the Action to post the picture into the supplied folder uploads.
Hence we need to create a folder in the main directory with CHMOD 777 [all permissions] to enable the files to be uploaded.
The form is basic input fields.
Files that are larger than the allocated amount will not be uploaded.
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 01:35 AM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.15811110 seconds (100.00% PHP - 0% MySQL) with 20 queries