Welcome to Virtual Tutorial World Guest!



PHP Uploader

 
Post new topic   Reply to topic    VTW Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Please Register and Login to this forum to stop seeing this advertsing.





Tokens:


Posted:     Post subject:

Back to top
computergeek67
Administrator
Administrator


Joined: 31 Jul 2007
Posts: 144


Tokens: 147
Location: US

PostPosted: Thu Dec 06, 2007 9:54 pm    Post subject: PHP Uploader Reply with quote

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:<br>

<input type='file' name='filename'><p>
<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 ("<b>File too big!  Try again...</b>");
    
    
    copy($_FILES["filename"]["tmp_name"],"./".$_FILES["filename"]["name"]) or die("<b><font color='red'>Unknown error! Please e-mail me if the problem persists.</b></font>");
    echo "<b><font color='green'>File Uploaded. <a href='../uploads/' target='_blank'>Click here</a> to see your file(s).</b></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.

-The Anizone



_________________



Come to me if you have any questions
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    VTW Forum Index -> PHP All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Virtual Tutorial World ©2007-2008 computergeek67

Affiliates