...

View Full Version : Problems uploading a file



thesavior
09-02-2006, 01:59 AM
Im having problems uploading a file from my form. Here is my script to validate, add to database, and upload to my directory.



if($_POST['form1sent'] == '1')
{
$catid = $_POST['id'];
$imagedesc = $_POST['imagedesc'];
$imagename = $_POST['imagename'];
if((strlen($imagename) < 3) || (strlen($imagename) > 30) )
{
$length = strlen($imagename);
badrequest("Your tutorial name must be between 3 and 30 characters. Your title was ".$length." characters long.");
}
else
{
if(strlen($imagedesc) > 65535)
{
$length = strlen($imagedesc);
badrequest("Your tutorial description must be less than 65535 characters. Your description was ".$length." characters long.");
}
else
{
clearstatcache();
$size = filesize($_FILES['image']['tmp_name']);
list($width,$height,$type)=getimagesize($_FILES['image']['tmp_name']);
if($type != (1||2||3||6) || $size >= 1101064)
{
badrequest("Your image may only be in the formats gif, jpg, png, or bmp. Your file must also be less then 1.5 megabytes.");
}
else
{
$types = array(
1 => 'GIF',
2 => 'JPG',
3 => 'PNG',
4 => 'SWF',
5 => 'PSD',
6 => 'BMP',
7 => 'TIFF(intel byte order)',
8 => 'TIFF(motorola byte order)',
9 => 'JPC',
10 => 'JP2',
11 => 'JPX',
12 => 'JB2',
13 => 'SWC',
14 => 'IFF',
15 => 'WBMP',
16 => 'XBM'
);
$ext = $types[$type];
$uploaddir = ROOT."images/";
$time = date('ymdHisB');
$uploadfile = $uploaddir."/".$time.$ext;
$location = "http://images.image-space.net/".$time.$ext;
move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile);

$catid2 = $db->escape($catid);
$imagedesc2 = $db->escape($imagedesc);
$imagename2 = $db->escape($imagename);

$db->query("INSERT INTO tutorials
(`parentid`,`dateuploaded`,`name`,`description`,`location`)
VALUES
('".$catid2."',now(),'".$imagename2."','".$imagedesc2."','".$location."')") or badrequest("An error occured uploading your image.");
redirect(ROOT.'member/image_sub.php', "Image uploaded successfully..");
}
}
}
}

My form looks like this:



<form action="image_sub.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="form1sent" value="1" />
<p>
<b>Image Title:</b><br />
<input type="text" name="imagename" /><br /><br />
<b>Choose the category:</b><br />
<select class="select" name="id">
<optgroup class="maincat" label="Digital Art">
<option class="sub first" value="2">3D Art</option>
<option class="sub" value="3">Drawings</option>
<option class="sub" value="4">Miscellaneous</option>
<option class="sub" value="5">Photo Manipulation</option>
<option class="sub" value="6">Wallpapers</option>
<optgroup class="subcat" label="Internet Use">
<option class="subcatsub first" value="8">Signatures</option>
<option class="subcatsub" value="9">Avatars</option>
</optgroup>
</optgroup>
<optgroup class="maincat" label="Photography">
<option class="sub first" value="13">Architecture</option>
<option class="sub" value="12">Portrait</option>
<option class="sub" value="11">Landscape</option>
</optgroup>
</select>&nbsp;
<br />
<br />
<b>Select your file:</b><br />
<input type="file" class="fileupload" name="image" />
<br />
<br />
<b>Description:</b><br />
<textarea name="imagedesc" cols="40" rows="6"></textarea>
<br />
<br />
<input type="submit" value="Upload" />
</p>
</form>


Im not getting any of my errors, or errors from php. What is happening, is that the page just loads and loads. It has been "loading" for 34 minutes and the file is a tad over 1 megabyte. Ive uploaded files this large by form before and it has never taken more than 45 seconds. Any ideas what could be going wrong?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum