Jump to content

Getting no result when uploading large file


rondog

Recommended Posts

I am trying to upload a 29mb file. I am using this code which works fine with smaller files:

if(isset($_POST['add']))
{
	$lastPosition = mysql_query("SELECT position from $table ORDER BY position DESC LIMIT 1") or die(mysql_error());
	$row = mysql_fetch_array($lastPosition);
	$newPosition = (int)$row['position'] + 1;
	$title = addslashes($_POST['title']);
	$flv = strtolower( str_replace( " ", "_", basename( $_FILES['flv']['name'] ) ) );

	$flvPathUL = "../".$flvPath."/".$flv;
	$move = move_uploaded_file($_FILES['flv']['tmp_name'], $flvPathUL);
	if($move)
	{
		$sql = mysql_query("INSERT INTO $table (position,title,src,thumbnail,type) VALUES ('$newPosition','$title','$flvPath/$flv','null','flv')") or die(mysql_error());
		if($sql)
		{
			$status = "Video Successfully added!";
		}
		else
		{
			$status = "Failed inserting Video Into Database. Please check your config and make sure you table name is correct.";
		}
	}
	else
	{
		$status = "Failed to upload FLV. Please check your config and make sure your folder names are right. Also make sure the folders have 777 permissions.";
	}
}

 

I was thinking that I just needed a max_file_size hidden field, but that didnt fix it. This is equivalent to 200mb

<input type="hidden" name="MAX_FILE_SIZE" value="209715200" />

 

I am thinking its maybe timing out because none of those $status strings are being echoed once the page refreshes. Any idea why?

 

Link to comment
Share on other sites

post_max_size integer

Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.

 

If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.

 

When an integer is used, the value is measured in bytes. You may also use shorthand notation as described in this FAQ.

 

If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.

 

If both the $_POST and $_FILES arrays are empty, the upload exceeds the post_max_size setting.

 

However, your code is not checking the $_FILES['flv']['error'] element, so there could be a different problem occurring - http://us3.php.net/manual/en/features.file-upload.errors.php

Link to comment
Share on other sites

The $_POST array will be empty as well, so $_POST['add'] won't be set in your code and none of your code inside of the if() block will be executed. You would need to put any check first in your code.

 

The normal way (in addition to using a GET value on the end of the URL that the php manual mentioned) is to check if $_SERVER['REQUEST_METHOD'] is 'POST', meaning a POST form requested the page and then to test if the $_POST array and/or $_FILES array is empty.

Link to comment
Share on other sites

Ok I checked phpinfo();

 

post_max_size 8M 8M

upload_max_filesize 20M 20M

 

That is obviously my problem. Now I just need access to my php.ini file..Damn shared host accounts! I remember 1and1 having an option somewhere that gives you access to your php.ini file..the phpinfo says its located at /usr/lib/php5/php.ini

 

but I have no access to that folder through my ftp..hmmmm

Link to comment
Share on other sites

Even after you manage to change the setting, your code still needs to check for this condition, because sooner or later someone will attempt to upload a file large enough to exceed the setting and do you want them to be greeted with a blank web page when they do?

Link to comment
Share on other sites

Well crap doing that still didnt work  :-[ hmmmm

 

Going back to error checking..would this be correct sp far?

if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if($_POST != empty)
	{
		if(isset($_POST['add']))
		{
			$lastPosition = mysql_query("SELECT position from $table ORDER BY position DESC LIMIT 1") or die(mysql_error());
			$row = mysql_fetch_array($lastPosition);
			$newPosition = (int)$row['position'] + 1;
			$title = addslashes($_POST['title']);
			$flv = strtolower( str_replace( " ", "_", basename( $_FILES['flv']['name'] ) ) );

			$flvPathUL = "../".$flvPath."/".$flv;
			$move = move_uploaded_file($_FILES['flv']['tmp_name'], $flvPathUL);
			echo $_FILES['flv']['error'];
			if($move)
			{
				$sql = mysql_query("INSERT INTO $table (position,title,src,thumbnail,type) VALUES ('$newPosition','$title','$flvPath/$flv','null','flv')") or die(mysql_error());
				if($sql)
				{
					$status = "Video Successfully added!";
				}
				else
				{
					$status = "Failed inserting Video Into Database. Please check your config and make sure you table name is correct.";
				}
			}
			else
			{
				$status = "Failed to upload FLV. Please check your config and make sure your folder names are right. Also make sure the folders have 777 permissions.";
			}
		}
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.