So I read thrue the internet trying to find a solution for this. I have changed some settings in the -htaccess file, making it look something like this:
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
php_value memory_limit 20M
Small files work great but larger then 1mb and my script gives me the "Error uploading file". My script looks like this:
<?
$uploadDir = '../../upload/admin_filer/';
if(isset($_POST['upload4']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$comment = $_POST['comment'];
$ext = substr(strrchr($fileName, "."), 1);
$randName = md5(rand() * time());
$filePath = $uploadDir . $randName . '.' . $ext;
$filePath2 = $randName . '.' . $ext;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include 'library/config.php';
include 'library/opendb.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO upload4 (name, size, type, path, path2, comment ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$filePath2', '$comment')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
echo "$fileName har laddats upp";
include 'library/closedb.php';
}
?>
Anyone got any idea of whats wrong?
*Edit: Forgot that I had a limit in the upload box, oops 🙂