PDA

View Full Version : I keep getting this error...



Forge
05-12-2007, 08:03 PM
Im making my first php script so bare with me! every time i try and upload an image it keeps saying that the file is too big! but it isnt!
can anyone spot the error in my code?



<html>
<head>
<title>YOURSITE.com - Image Upload By Forge</title>
</head>
<body>
<form action='index.php' method='post' enctype='multipart/form-data'>
Browse a File to Upload:<br>
<input type='file' name='filetoupload'><br>
<input type='hidden' name='max_image_size' value='<?echo $sizelimit; ?>'>
<br>
<input type='Submit' value='Upload File'>
</form>
</body>
</html>
<?php
include 'config.php';
include 'english.lang.php';
include 'style.css';
if (!is_dir("$uploadfolder")) {
die ("
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: The specified folder ($uploadfolder) doesn't exist!</font></td>
</tr>
</table>
");
}
if (!is_writeable("$uploadfolder")){
die ("
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: The specified folder ($uploadfolder) isn't writeable. Please CHMOD it to 777</font></td>
</tr>
</table>
");
}
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{

$size = $_FILES['filetoupload']['size'];
if ($size > $limit)
{
echo "
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: Your file is too large. It must be $sizelimit KB or less!</font></td>
</tr>
</table>
";
exit();
}
if (($limitfiletype == "yes") && (!in_array($_FILES['filetoupload']['type'],$filetypes)))
{
echo"
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: Wrong file type. You are allowed the following file types.<br>
.gif<br>
.jpeg<br>
.jpg<br>
.png<br>
.PNG<br>
.bmp</font></td>
</tr>
</table>
";
exit();
}
$filename = $_FILES['filetoupload']['name'];
if(file_exists($uploadfolder.$filename)){
echo "
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>$filename already exists on our servers!</font></td>
</tr>
</table>
";
exit();
}
if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$uploadfolder.$filename)) {
echo "<img src='$uploadfolder$filename'> <br>
Direct link<br>
<input size='60' value='$upload_dir$filename'>";
exit();
}
}
?>

zeJosh
05-12-2007, 08:13 PM
I got an idea!

MAKE YOUR OWN SCRIPT AND STOP USING THEM OFF TUTORIAL SITES
YOU SAD PERSON!

Edited by opensourcehost (Forum Super Moderator): Please do not be rude.

Forge
05-12-2007, 08:20 PM
Get lost! this isnt! ive spent bloody ages on this!

vTaz
05-12-2007, 08:21 PM
I got an idea!

MAKE YOUR OWN SCRIPT AND STOP USING THEM OFF TUTORIAL SITES
YOU SAD PERSON!

How else do people learn stuff without tutorials ..

.L!nK.
05-12-2007, 08:22 PM
Ask the person who made it ;)

Forge
05-12-2007, 08:23 PM
ive been reading loads of tutorials to make this from various websites but i assure you i made this script.

zeJosh
05-12-2007, 08:28 PM
Taz, he downloaded a free script, and edited it

Forge
05-12-2007, 08:30 PM
zeJosh. Get lost. i havent so sort your head out and then read this post again.

vTaz
05-12-2007, 08:31 PM
Taz, he downloaded a free script, and edited it


does it really matter?, why take it that serious. i mean if he wants too call it his script let him.. i don't really care to be honest. that's the thing with this forum everyone takes this stuff serious..

MrCraig
05-12-2007, 08:32 PM
<html>
<head>
<title>YOURSITE.com - Image Upload By Forge</title>
</head>
<body>
<form action='index.php' method='post' enctype='multipart/form-data'>
Browse a File to Upload:<br>
<input type='file' name='filetoupload'><br>
<input type='hidden' name='max_image_size' value='<?echo $sizelimit; ?>'>
<br>
<input type='Submit' value='Upload File'>
</form>
</body>
</html>
<?php
include 'config.php';
include 'english.lang.php';
include 'style.css';
$limit = 50000;
if (!is_dir("$uploadfolder")) {
die ("
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: The specified folder ($uploadfolder) doesn't exist!</font></td>
</tr>
</table>
");
}
if (!is_writeable("$uploadfolder")){
die ("
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: The specified folder ($uploadfolder) isn't writeable. Please CHMOD it to 777</font></td>
</tr>
</table>
");
}
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{

$size = $_FILES['filetoupload']['size'];
if ($size > $limit)
{
echo "
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: Your file is too large. It must be $sizelimit KB or less!</font></td>
</tr>
</table>
";
exit();
}
if (($limitfiletype == "yes") && (!in_array($_FILES['filetoupload']['type'],$filetypes)))
{
echo"
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>ERROR: Wrong file type. You are allowed the following file types.<br>
.gif<br>
.jpeg<br>
.jpg<br>
.png<br>
.PNG<br>
.bmp</font></td>
</tr>
</table>
";
exit();
}
$filename = $_FILES['filetoupload']['name'];
if(file_exists($uploadfolder.$filename)){
echo "
<table border='1' style='border-collapse: collapse' bordercolor='#FF0000' bgcolor='#EFEFEF'>
<tr>
<td><font family='Franklin Gothic Book' size='1' color='#FF0000'>$filename already exists on our servers!</font></td>
</tr>
</table>
";
exit();
}
if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$uploadfolder.$filename)) {
echo "<img src='$uploadfolder$filename'> <br>
Direct link<br>
<input size='60' value='$upload_dir$filename'>";
exit();
}
}
?>

Invent
05-12-2007, 08:33 PM
What's $limit defined as? (If you have defined it...)

Forge
05-12-2007, 08:37 PM
This is the config file. The image i was trying to upload is 1.67KB


<?php

$uploadfolder = 'images/'; //The folder in which the images will be uploaded to.
$sizelimit = '5000'; //The max size of the file you can upload. Measured in KB.
$filetypes = array('image/gif',
'image/pjpeg',
'image/jpeg',
'image/png',
'image/PNG',
'image/bmp',
'image/jpg'); //Types of files allowed to be uploaded.
$limitfiletype = 'yes'; //Whether you want the types of uploaded files to be limited (yes/no)


?>

MrCraig
05-12-2007, 08:39 PM
try my vers forge

You havent defined limit so it thinks its 0.

Forge
05-12-2007, 08:43 PM
Thanks CJ555 & Invent! It was just that the limit wasn't defined! Silly me i thought i already had because i had defined $sizelimit! woops! :D +REP!

MrCraig
05-12-2007, 08:46 PM
Nps :)

REP returned

Want to hide these adverts? Register an account for free!