Jump to content

Recommended Posts

Can you increase the max file size for an upload through php rather than changing the php.ini? I tried uploading a 15mb file and it didnt work, but if I upload a 1mb file it works so I am assuming thats the problem. Here is my file:

<?php
$host 	= "HOST";
$username 	= "USERNAME";
$password 	= "PASSWORD";
$db_name 	= "DATABASE";

$con = mysql_connect($host,$username,$password);
if (!$con)
{
echo "unable to connect to DB";
echo mysql_error($con);
exit();
}


$db = mysql_select_db($db_name);
if (!$db)
{
echo "unable to open DB";
echo mysql_error($db);
exit();
}

//data vars
$type 		= $_POST['type'];
$projID 		= $_POST['projectID'];
$title 		= $_POST['itemTitle'];
$description 	= $_POST['itemDescription'];


/*********************
* upload file
*********************/
if (isset($type))
{
$query = mysql_query("SELECT MAX(position) AS position FROM projectData WHERE proj_id = '$projID'");
$row = mysql_fetch_assoc($query);
$pos = $row['position'] + 1;

if ($query)
{	
	$addTime		= mktime();
	$l_sFileName	= strtolower( str_replace( " ", "_", basename( $_FILES['Filedata']['name'] ) ) );
	$l_sFilePath		= "project_data/".$addTime.$l_sFileName;
	$fname		= "project_data/".$addTime.$l_sFileName;

	move_uploaded_file( $_FILES['Filedata']['tmp_name'], $l_sFilePath );

	$sql = mysql_query("INSERT INTO projectData (proj_id,position,type,path,title,description) VALUES ('$projID','$pos','$type','$fname','$title','$description')");
}
}
else
{
echo "Go away!";
}
?>

You can set php settings in a .htaccess file only if php is running as an Apache module. You should probably also set the post max size -

php_value upload_max_filesize 100M
php_value post_max_size 100M

You can set php settings in a .htaccess file only if php is running as an Apache module. You should probably also set the post max size -

php_value upload_max_filesize 100M
php_value post_max_size 100M

 

I just tried that and I get a 500 internal server error..does that mean my host isnt running apache?

500 internal server error..does that mean my host isnt running apache?
It means it is not running php as an Apache module.

 

Php is probably running as a CGI application, so you can probably change them in a local php.ini

 

You should actually just check with your web host how to change these particular settings on his server as he may in fact prevent you from changing them at all.

500 internal server error..does that mean my host isnt running apache?
It means it is not running php as an Apache module.

 

Php is probably running as a CGI application, so you can probably change them in a local php.ini

 

You should actually just check with your web host how to change these particular settings on his server as he may in fact prevent you from changing them at all.

 

I checked a little bit ago and they said you create a php.ini file and upload it to whatever folder you want the changes in, which I did and it works. I guess it over writes the main php.ini settings. The only reason I want to do this in code is because I will be selling this product so I wanted it as easy as possible. I'll just have to add that to the FAQ/Help section. Thanks for the help. I guess I could say this topic is solved.

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.