Lefora Free Forum
0 views

Create a Simple uploading script

Page 1
posts 1–1 of 1
rookie - member
2 posts

Time to create: 10-15min.

You can use, abuse and mod this script all you want to create your file host script ^^ This script will allow immages smaller than 2MB to be uploaded. you can however easily change this simply by editing a few obvious variables!

PHP Code:

Quote:
<?php

//This function will display your form
function form(){

echo "<form action='?act=upload' enctype='multipart/form-data' method='post'>"
."Select your file for upload: <input type='file' name='file' size='30'>&nbsp;"
."<input type='submit' value='Upload'>";

}

//This function will upload your file
function upload(){

//Let's collect all info into variables
$file = $_FILES['file']['name'];
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];
$temp = $_FILES["file"]["tmp_name"];

//Let's set max file size to 2mb
$max_size = "2097152";

//Now set allowed file types
$allow_type_1 = "image/jpeg";
$allow_type_2 = "image/gif";
$allow_type_3 = "image/png";
$allow_type_4 = "image/bmp";

//If file size is bigger than 2mb than let's display an error
if($size > 2097152){
die("File is to big!");
}

Page 1
posts 1–1 of 1

This Topic Is Locked To Guest Posts

It's been a while since this topic was active, if you'd like to get it going again, please post as a registered member

join now