Drompo
27-05-2007, 08:31 PM
Right, some of you have requested a better version of my pervious script so here it is.
<?
// Uploader Script made by E-Ash off Habbo UK
// CONFIG
$siteurl = "http://www."; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above WITH trailing slash
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "500000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG ENDThis is the start of your code. This is the configuration part.
$siteurl - eg. http://www.habboxforum.com/images (NO TRAILING SLASH)
$serverpath - eg. images/ (LEAVE TRAILING SLASH)
$maxsize - The maximum size that a file can be befor it is restricted.
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}This Is the Form where you select the file to upload. This is self-explanatory.
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";This is the allowed files section. What ever files you want to allow to be uploaded just insert
$allowedfiles[] = "EXTENTION"; In both upper and lower case letters
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>That is all the process stuff
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->This is all the output code of the Direct links and BB codes.
You can add what ever you like as long its between the Hidden Text.
<?php
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>
And that is the error message if it hasn't been uploaded.
And thats now complete
Full Version below
__________________________________________________ _____________
<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www."; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "500000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>
<?
// Uploader Script made by E-Ash off Habbo UK
// CONFIG
$siteurl = "http://www."; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above WITH trailing slash
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "500000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG ENDThis is the start of your code. This is the configuration part.
$siteurl - eg. http://www.habboxforum.com/images (NO TRAILING SLASH)
$serverpath - eg. images/ (LEAVE TRAILING SLASH)
$maxsize - The maximum size that a file can be befor it is restricted.
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}This Is the Form where you select the file to upload. This is self-explanatory.
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";This is the allowed files section. What ever files you want to allow to be uploaded just insert
$allowedfiles[] = "EXTENTION"; In both upper and lower case letters
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>That is all the process stuff
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->This is all the output code of the Direct links and BB codes.
You can add what ever you like as long its between the Hidden Text.
<?php
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>
And that is the error message if it hasn't been uploaded.
And thats now complete
Full Version below
__________________________________________________ _____________
<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www."; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "500000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>