Upload script won't upload more than 1.5mb

I’ve got a simple php upload script but it doesn’t want to upload more than 1.5mb. The browser seems to time out. Any help would be greatly appreciated.

Thanks

[php]
if (($_FILES[“file”][“size”] < 3000000)) // limit upload to 3mb
{
if ($_FILES[“file”][“error”] > 0)
{
echo "Return Code: " . $_FILES[“file”][“error”] . “
”;
}
else
{
echo "Upload: " . $_FILES[“file”][“name”] . “
”;
echo "Type: " . $_FILES[“file”][“type”] . “
”;
echo “Size: " . ($_FILES[“file”][“size”] / 1024) . " Kb
”;
echo "Temp file: " . $_FILES[“file”][“tmp_name”] . “
”;

		if (file_exists($folder . $_FILES["file"]["name"]))
		  {
		  echo $_FILES["file"]["name"] . " already exists. ";
		  }
		else
		  {
		  move_uploaded_file($_FILES["file"]["tmp_name"], stripslashes($_FILES["file"]["name"]));
		  header('location: index.php');
		  }
		}
	}
	else
		{
	  echo "Invalid file";
		}

[/php]

there is a time limit for scripts to run i think 30 seconds is the default…

does your host allow you to upload files of this size?
reason i ask is i once had a host with a file size limit of 512kb (half a meg!) kinda ran into issues day after day trying to upload files for downloads etc…
needless to say, i’m no longer with said host… ;D

Interesting…

Maybe thats why i’m having problems working on my website. I’m just dabbling in web design with free hosting. Thanks for the info I’ll have to contact them and see what they say.

Thanks.

if you have a control panel in your free hosting, it usually tells you in there…

Your right, php upload scripts are limited to 2mb file size. So if I limit my script to 2mb I should be fine.

Thanks for your help!
Dave

Hi mate,

I kinda had a gut feeling it was this because timeouts are hard to achieve nowadays (broadband etc) unless your script is either:
a. Massive (like thousands of lines).
b. Uploading/processing a fair amount of data.
c. Broken… (infinite while loops etc).

Anyway, i’m glad you fixed it (kind of) and happy to of helped :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service